mirror of https://github.com/CIRCL/PyCIRCLean
Add __repr__s to File and KittenGroomerFileCheck
parent
92d77e1a82
commit
159bc9cee2
|
@ -124,7 +124,7 @@ class File(FileBase):
|
||||||
filetype-specific processing methods.
|
filetype-specific processing methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, src_path, dst_path, logger):
|
def __init__(self, src_path, dst_path, logger=None):
|
||||||
super(File, self).__init__(src_path, dst_path)
|
super(File, self).__init__(src_path, dst_path)
|
||||||
self.is_archive = False
|
self.is_archive = False
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
@ -162,6 +162,9 @@ class File(FileBase):
|
||||||
'inode': self.inode,
|
'inode': self.inode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<filecheck.File object: {{{}}}>".format(self.filename)
|
||||||
|
|
||||||
def _check_dangerous(self):
|
def _check_dangerous(self):
|
||||||
if not self.has_mimetype:
|
if not self.has_mimetype:
|
||||||
self.make_dangerous('File has no mimetype')
|
self.make_dangerous('File has no mimetype')
|
||||||
|
@ -248,13 +251,16 @@ class File(FileBase):
|
||||||
|
|
||||||
def write_log(self):
|
def write_log(self):
|
||||||
"""Pass information about the file to self.logger"""
|
"""Pass information about the file to self.logger"""
|
||||||
props = self.get_all_props()
|
if self.logger:
|
||||||
if not self.is_archive:
|
props = self.get_all_props()
|
||||||
if os.path.exists(self.tempdir_path):
|
if not self.is_archive:
|
||||||
# FIXME: in_tempdir is a hack to make images appear at the correct tree depth in log
|
if os.path.exists(self.tempdir_path):
|
||||||
self.logger.add_file(self.src_path, props, in_tempdir=True)
|
# FIXME: in_tempdir is a hack to make images appear at the correct tree depth in log
|
||||||
return
|
self.logger.add_file(self.src_path, props, in_tempdir=True)
|
||||||
self.logger.add_file(self.src_path, props)
|
return
|
||||||
|
self.logger.add_file(self.src_path, props)
|
||||||
|
else:
|
||||||
|
raise Warning("No logger associated with this File")
|
||||||
|
|
||||||
# ##### Helper functions #####
|
# ##### Helper functions #####
|
||||||
def _make_method_dict(self, list_of_tuples):
|
def _make_method_dict(self, list_of_tuples):
|
||||||
|
@ -676,6 +682,11 @@ class KittenGroomerFileCheck(KittenGroomerBase):
|
||||||
self.max_recursive_depth = max_recursive_depth
|
self.max_recursive_depth = max_recursive_depth
|
||||||
self.logger = GroomerLogger(root_src, root_dst, debug)
|
self.logger = GroomerLogger(root_src, root_dst, debug)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "filecheck.KittenGroomerFileCheck object: {{{}}}".format(
|
||||||
|
os.path.basename(self.src_root_path)
|
||||||
|
)
|
||||||
|
|
||||||
def process_dir(self, src_dir, dst_dir):
|
def process_dir(self, src_dir, dst_dir):
|
||||||
"""Process a directory on the source key."""
|
"""Process a directory on the source key."""
|
||||||
for srcpath in self.list_files_dirs(src_dir):
|
for srcpath in self.list_files_dirs(src_dir):
|
||||||
|
|
Loading…
Reference in New Issue