Make list_all_files a public method

pull/12/head
Dan Puttick 2017-02-24 10:43:42 -05:00
parent 4a99ba900a
commit 3d36c90d66
6 changed files with 6 additions and 7 deletions

View File

@ -570,7 +570,7 @@ class KittenGroomerFileCheck(KittenGroomerBase):
if self.recursive_archive_depth >= self.max_recursive_depth: if self.recursive_archive_depth >= self.max_recursive_depth:
self._handle_archivebomb(src_dir) self._handle_archivebomb(src_dir)
for srcpath in self._list_all_files(src_dir): for srcpath in self.list_all_files(src_dir):
dstpath = srcpath.replace(src_dir, dst_dir) dstpath = srcpath.replace(src_dir, dst_dir)
relative_path = srcpath.replace(src_dir + '/', '') relative_path = srcpath.replace(src_dir + '/', '')
self.process_file(srcpath, dstpath, relative_path) self.process_file(srcpath, dstpath, relative_path)

View File

@ -339,7 +339,7 @@ class KittenGroomer(KittenGroomerBase):
archbomb_path = src_dir[:-len('_temp')] archbomb_path = src_dir[:-len('_temp')]
self._safe_remove(archbomb_path) self._safe_remove(archbomb_path)
for srcpath in self._list_all_files(src_dir): for srcpath in self.list_all_files(src_dir):
self.cur_file = File(srcpath, srcpath.replace(src_dir, dst_dir)) self.cur_file = File(srcpath, srcpath.replace(src_dir, dst_dir))
self.log_name.info('Processing {} ({}/{})', srcpath.replace(src_dir + '/', ''), self.log_name.info('Processing {} ({}/{})', srcpath.replace(src_dir + '/', ''),

View File

@ -54,7 +54,7 @@ class KittenGroomerPier9(KittenGroomerBase):
''' '''
Main function doing the processing Main function doing the processing
''' '''
for srcpath in self._list_all_files(self.src_root_dir): for srcpath in self.list_all_files(self.src_root_dir):
self.log_name.info('Processing {}', srcpath.replace(self.src_root_dir + '/', '')) self.log_name.info('Processing {}', srcpath.replace(self.src_root_dir + '/', ''))
self.cur_file = FilePier9(srcpath, srcpath.replace(self.src_root_dir, self.dst_root_dir)) self.cur_file = FilePier9(srcpath, srcpath.replace(self.src_root_dir, self.dst_root_dir))
if not self.cur_file.is_dangerous() and self.cur_file.extension in self.authorized_extensions: if not self.cur_file.is_dangerous() and self.cur_file.extension in self.authorized_extensions:

View File

@ -54,7 +54,7 @@ class KittenGroomerSpec(KittenGroomerBase):
''' '''
to_copy = [] to_copy = []
error = [] error = []
for srcpath in self._list_all_files(self.src_root_dir): for srcpath in self.list_all_files(self.src_root_dir):
valid = True valid = True
self.log_name.info('Processing {}', srcpath.replace(self.src_root_dir + '/', '')) self.log_name.info('Processing {}', srcpath.replace(self.src_root_dir + '/', ''))
self.cur_file = FileSpec(srcpath, srcpath.replace(self.src_root_dir, self.dst_root_dir)) self.cur_file = FileSpec(srcpath, srcpath.replace(self.src_root_dir, self.dst_root_dir))

View File

@ -274,8 +274,7 @@ class KittenGroomerBase(object):
print(e) print(e)
return False return False
# TODO: this isn't a private method, change and edit the groomers as well def list_all_files(self, directory):
def _list_all_files(self, directory):
"""Generator yielding path to all of the files in a directory tree.""" """Generator yielding path to all of the files in a directory tree."""
for root, dirs, files in os.walk(directory): for root, dirs, files in os.walk(directory):
for filename in files: for filename in files:

View File

@ -271,7 +271,7 @@ class TestKittenGroomerBase:
testdir = tmpdir.join('testdir') testdir = tmpdir.join('testdir')
os.mkdir(testdir.strpath) os.mkdir(testdir.strpath)
simple_groomer = KittenGroomerBase(tmpdir.strpath, tmpdir.strpath) simple_groomer = KittenGroomerBase(tmpdir.strpath, tmpdir.strpath)
files = simple_groomer._list_all_files(simple_groomer.src_root_dir) files = simple_groomer.list_all_files(simple_groomer.src_root_dir)
assert file.strpath in files assert file.strpath in files
assert testdir.strpath not in files assert testdir.strpath not in files