From 3d36c90d6612ca0ca2386b38d5073fe5ba040eb7 Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Fri, 24 Feb 2017 10:43:42 -0500 Subject: [PATCH] Make list_all_files a public method --- bin/filecheck.py | 2 +- examples/generic.py | 2 +- examples/pier9.py | 2 +- examples/specific.py | 2 +- kittengroomer/helpers.py | 3 +-- tests/test_kittengroomer.py | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/filecheck.py b/bin/filecheck.py index 54be51a..a7e8ab5 100644 --- a/bin/filecheck.py +++ b/bin/filecheck.py @@ -570,7 +570,7 @@ class KittenGroomerFileCheck(KittenGroomerBase): if self.recursive_archive_depth >= self.max_recursive_depth: 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) relative_path = srcpath.replace(src_dir + '/', '') self.process_file(srcpath, dstpath, relative_path) diff --git a/examples/generic.py b/examples/generic.py index e76fccd..220b3db 100644 --- a/examples/generic.py +++ b/examples/generic.py @@ -339,7 +339,7 @@ class KittenGroomer(KittenGroomerBase): archbomb_path = src_dir[:-len('_temp')] 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.log_name.info('Processing {} ({}/{})', srcpath.replace(src_dir + '/', ''), diff --git a/examples/pier9.py b/examples/pier9.py index 6ded725..9252c4f 100644 --- a/examples/pier9.py +++ b/examples/pier9.py @@ -54,7 +54,7 @@ class KittenGroomerPier9(KittenGroomerBase): ''' 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.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: diff --git a/examples/specific.py b/examples/specific.py index fcca2f4..724ba35 100644 --- a/examples/specific.py +++ b/examples/specific.py @@ -54,7 +54,7 @@ class KittenGroomerSpec(KittenGroomerBase): ''' to_copy = [] 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 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)) diff --git a/kittengroomer/helpers.py b/kittengroomer/helpers.py index 7e2a433..9f7cced 100644 --- a/kittengroomer/helpers.py +++ b/kittengroomer/helpers.py @@ -274,8 +274,7 @@ class KittenGroomerBase(object): print(e) 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.""" for root, dirs, files in os.walk(directory): for filename in files: diff --git a/tests/test_kittengroomer.py b/tests/test_kittengroomer.py index bd16c5a..8339e84 100644 --- a/tests/test_kittengroomer.py +++ b/tests/test_kittengroomer.py @@ -271,7 +271,7 @@ class TestKittenGroomerBase: testdir = tmpdir.join('testdir') os.mkdir(testdir.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 testdir.strpath not in files