def test_DirPaths_created_at(self):
        dp = DirPaths(directory, full_paths=True, parallelize=True, console_stream=CONSOLE_STREAM)
        dp.walk()
        file_created = dp.creation_dates(sort=True)

        for path, created_at in file_created:
            self.assertTrue(os.path.exists(path))
            self.assertTrue(isinstance(created_at, datetime))
Beispiel #2
0
    def flatten(self):
        for dirs in tqdm(self.root_paths,
                         desc='Flattening file tree',
                         total=len(self.root_paths)):
            files = DirPaths(dirs)
            for f in files:
                if self.target == 'directory':
                    shutil.move(f, dirs)
                    self.remove_path_dirname(f)

                elif self.target == 'root':
                    shutil.move(f, self.directory)
                    self.remove_path_dirname(f)
                    self.remove_path_dirname(os.path.dirname(f))
 def test_DirPaths_hash(self):
     paths = DirPaths(directory, full_paths=True, parallelize=False, hash_files=True,
                      console_stream=CONSOLE_STREAM).walk()
     for path, _hash in paths:
         self.assertTrue(os.path.exists(path))
         self.assertEqual(_hash, md5_hash(path))
 def test_DirPaths_sequential_nofilters(self):
     paths = DirPaths(directory, full_paths=True, parallelize=False, to_exclude=False,
                      console_stream=CONSOLE_STREAM).walk()
     for i in paths:
         self.assertTrue(os.path.exists(i))
 def test_DirPaths_multiprocess(self):
     paths = DirPaths(directory, full_paths=True, parallelize=True, console_stream=CONSOLE_STREAM).walk()
     for i in paths:
         self.assertTrue(os.path.exists(i))
Beispiel #6
0
 def __init__(self, root, delimiter="_", prefix=None, suffix=None):
     self.files = DirPaths(root).files()
     self.delimiter = delimiter
     self.prefix = prefix
     self.suffix = suffix
     self.create()
Beispiel #7
0
 def _get_paths(self):
     return DirPaths(self.source, full_paths=True).walk()