Make self.get_extension return a value

pull/12/head
Dan Puttick 2017-02-24 10:41:59 -05:00
parent c6ecc5e3a3
commit 4a99ba900a
1 changed files with 5 additions and 4 deletions

View File

@ -45,13 +45,13 @@ class FileBase(object):
# TODO: rename this. file_information? file_data? file_metadata? file_log? # TODO: rename this. file_information? file_data? file_metadata? file_log?
self.log_details = {'filepath': self.src_path} self.log_details = {'filepath': self.src_path}
self.log_string = '' self.log_string = ''
self._determine_extension() self.extension = self._determine_extension()
self._determine_mimetype() self._determine_mimetype()
self.logger = logger self.logger = logger
def _determine_extension(self): def _determine_extension(self):
_, ext = os.path.splitext(self.src_path) _, ext = os.path.splitext(self.src_path)
self.extension = ext.lower() return ext.lower()
def _determine_mimetype(self): def _determine_mimetype(self):
if os.path.islink(self.src_path): if os.path.islink(self.src_path):
@ -60,7 +60,7 @@ class FileBase(object):
else: else:
try: try:
mt = magic.from_file(self.src_path, mime=True) mt = magic.from_file(self.src_path, mime=True)
# note: magic will always return something, even if it's just 'data' # Note: magic will always return something, even if it's just 'data'
except UnicodeEncodeError as e: except UnicodeEncodeError as e:
# FIXME: The encoding of the file is broken (possibly UTF-16) # FIXME: The encoding of the file is broken (possibly UTF-16)
mt = '' mt = ''
@ -223,8 +223,9 @@ class GroomerLog(object):
return s.hexdigest() return s.hexdigest()
def add_file(self): def add_file(self):
# File object will add itself
# return a sublog for the file
pass pass
# Should this return a sublog that the file can then write to? Does that work? Too confusing to understand?
def add_event(self, event, log_level): def add_event(self, event, log_level):
pass pass