Beispiel #1
0
    def test_access_recursion(self):
        paths = ['content/.DirectoryA', 'content/-DirectoryB']
        basenames = [
            'content/.DirectoryA/SubdirA', 'content/.DirectoryA/SubdirB',
            'content/.DirectoryA/SubdirC',
            'content/.DirectoryA/SubdirA/emptyfileA',
            'content/.DirectoryA/SubdirA/emptyfileB',
            'content/.DirectoryA/SubdirA/emptyfileC',
            'content/.DirectoryA/SubdirA/nonemptyA',
            'content/.DirectoryA/SubdirA/nonemptyB',
            'content/.DirectoryA/SubdirA/nonemptyC',
            'content/.DirectoryA/SubdirB/emptyA',
            'content/.DirectoryA/SubdirB/emptyB',
            'content/.DirectoryA/SubdirB/emptyC',
            'content/.DirectoryA/SubdirB/nonemptyA',
            'content/.DirectoryA/SubdirB/nonemptyB',
            'content/.DirectoryA/SubdirB/nonemptyC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.all(paths, access=os.W_OK, recursion=True)

        self.assertEqual(output, expected)
    def test_access_recursion(self):
        paths = ['content/DirectoryD\\n', 'content/DirectoryE']
        basenames = ['content/DirectoryE/SubdirA',
                    'content/DirectoryE/SubdirB',
                    'content/DirectoryE/SubdirC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths, access=os.W_OK, recursion=True)

        self.assertEqual(output, expected)
Beispiel #3
0
    def test_access_recursion(self):
        paths = ['content/DirectoryD\\n', 'content/DirectoryE']
        basenames = [
            'content/DirectoryE/SubdirA', 'content/DirectoryE/SubdirB',
            'content/DirectoryE/SubdirC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths, access=os.W_OK, recursion=True)

        self.assertEqual(output, expected)
    def test_filter_invalid_paths(self):
        paths = ['content/.DirectoryA', 'content/does_not_exist',
                 'content/does_not_exist/subdirectory']
        basenames = ['content/.DirectoryA/SubdirA',
                     'content/.DirectoryA/SubdirB',
                     'content/.DirectoryA/SubdirC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths)

        self.assertEqual(output, expected)
    def test_filter_invalid_paths(self):
        paths = ['content/.DirectoryA/SubdirB/emptyA',
                 'content/DirectoryD\\n/SubdirA/nonemptyA',
                 'content/does_not_exist/nonfile',
                 'content/does_not_exist/otherfile']
        basenames = ['content/.DirectoryA/SubdirB/emptyA',
                     'content/DirectoryD\\n/SubdirA/nonemptyA']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths)

        self.assertEqual(output, expected)
Beispiel #6
0
    def test_nonrecursive(self):
        paths = ['content']
        basenames = [
            'content/-DirectoryB', 'content/.DirectoryA',
            'content/DirectoryD\\n', 'content/DirectoryE',
            'content/DirectoryF', 'content/\\nDirectoryC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths)

        self.assertEqual(output, expected)
    def test_minsize_nonrecursive(self):
        paths = ['content/.DirectoryA/SubdirB']
        basenames = ['content/.DirectoryA/SubdirB/nonemptyA',
                     'content/.DirectoryA/SubdirB/nonemptyB',
                     'content/.DirectoryA/SubdirB/nonemptyC',
                     'content/.DirectoryA/SubdirB/nonempty_rootA',
                     'content/.DirectoryA/SubdirB/nonempty_rootB',
                     'content/.DirectoryA/SubdirB/nonempty_rootC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths, minsize=0)

        self.assertEqual(output, expected)
Beispiel #8
0
    def test_filter_invalid_paths(self):
        paths = [
            'content/.DirectoryA', 'content/does_not_exist',
            'content/does_not_exist/subdirectory'
        ]
        basenames = [
            'content/.DirectoryA/SubdirA', 'content/.DirectoryA/SubdirB',
            'content/.DirectoryA/SubdirC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths)

        self.assertEqual(output, expected)
    def test_nonrecursive(self):
        paths = ['content']
        basenames = ['content/-DirectoryB',
                     'content/.DirectoryA',
                     'content/DirectoryD\\n',
                     'content/DirectoryE',
                     'content/DirectoryF',
                     'content/\\nDirectoryC']


        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths)

        self.assertEqual(output, expected)
    def test_minsize_nonrecursive(self):
        paths = ['content/.DirectoryA/SubdirB']
        basenames = [
            'content/.DirectoryA/SubdirB/nonemptyA',
            'content/.DirectoryA/SubdirB/nonemptyB',
            'content/.DirectoryA/SubdirB/nonemptyC',
            'content/.DirectoryA/SubdirB/nonempty_rootA',
            'content/.DirectoryA/SubdirB/nonempty_rootB',
            'content/.DirectoryA/SubdirB/nonempty_rootC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths, minsize=0)

        self.assertEqual(output, expected)
    def test_filter_invalid_paths(self):
        paths = ['content', 'content/does_not_exist', 'content/does_not_exist/subdirectory']
        basenames = ['content/-DirectoryB',
                     'content/.DirectoryA',
                     'content/DirectoryD\\n',
                     'content/DirectoryE',
                     'content/DirectoryF',
                     'content/\\nDirectoryC',
                     'content/file1.txt',
                     'content/file2_nonempty.txt',
                     'content/file3.conf']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.all(paths)

        self.assertEqual(output, expected)
Beispiel #12
0
    def test_filter_invalid_paths(self):
        paths = [
            'content', 'content/does_not_exist',
            'content/does_not_exist/subdirectory'
        ]
        basenames = [
            'content/-DirectoryB', 'content/.DirectoryA',
            'content/DirectoryD\\n', 'content/DirectoryE',
            'content/DirectoryF', 'content/\\nDirectoryC', 'content/file1.txt',
            'content/file2_nonempty.txt', 'content/file3.conf'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.all(paths)

        self.assertEqual(output, expected)
    def test_filter_invalid_paths(self):
        paths = [
            'content/.DirectoryA/SubdirB/emptyA',
            'content/DirectoryD\\n/SubdirA/nonemptyA',
            'content/does_not_exist/nonfile',
            'content/does_not_exist/otherfile'
        ]
        basenames = [
            'content/.DirectoryA/SubdirB/emptyA',
            'content/DirectoryD\\n/SubdirA/nonemptyA'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths)

        self.assertEqual(output, expected)
Beispiel #14
0
    def test_recursion(self):
        paths = ['content']
        basenames = [
            'content/-DirectoryB', 'content/.DirectoryA',
            'content/DirectoryD\\n', 'content/DirectoryE',
            'content/DirectoryF', 'content/\\nDirectoryC',
            'content/.DirectoryA/SubdirA', 'content/.DirectoryA/SubdirB',
            'content/.DirectoryA/SubdirC', 'content/DirectoryD\\n/SubdirA',
            'content/DirectoryD\\n/SubdirB', 'content/DirectoryD\\n/SubdirC',
            'content/DirectoryE/SubdirA', 'content/DirectoryE/SubdirB',
            'content/DirectoryE/SubdirC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths, recursion=True)

        self.assertEqual(output, expected)
    def test_access_recursion(self):
        paths = ['content/.DirectoryA']
        basenames = ['content/.DirectoryA/SubdirA/emptyfileA',
                     'content/.DirectoryA/SubdirA/emptyfileB',
                     'content/.DirectoryA/SubdirA/emptyfileC',
                     'content/.DirectoryA/SubdirA/nonemptyA',
                     'content/.DirectoryA/SubdirA/nonemptyB',
                     'content/.DirectoryA/SubdirA/nonemptyC',
                     'content/.DirectoryA/SubdirB/emptyA',
                     'content/.DirectoryA/SubdirB/emptyB',
                     'content/.DirectoryA/SubdirB/emptyC',
                     'content/.DirectoryA/SubdirB/nonemptyA',
                     'content/.DirectoryA/SubdirB/nonemptyB',
                     'content/.DirectoryA/SubdirB/nonemptyC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths, access=os.W_OK, recursion=True)

        self.assertEqual(output, expected)
    def test_nonrecursive(self):
        paths = ['content/.DirectoryA/SubdirA', 'content/DirectoryE/SubdirA']
        basenames = ['content/.DirectoryA/SubdirA/emptyfileA',
                     'content/.DirectoryA/SubdirA/emptyfileB',
                     'content/.DirectoryA/SubdirA/emptyfileC',
                     'content/.DirectoryA/SubdirA/nonemptyA',
                     'content/.DirectoryA/SubdirA/nonemptyB',
                     'content/.DirectoryA/SubdirA/nonemptyC',
                     'content/DirectoryE/SubdirA/emptyfileA',
                     'content/DirectoryE/SubdirA/emptyfileB',
                     'content/DirectoryE/SubdirA/emptyfileC',
                     'content/DirectoryE/SubdirA/nonemptyA',
                     'content/DirectoryE/SubdirA/nonemptyB',
                     'content/DirectoryE/SubdirA/nonemptyC']


        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths)

        self.assertEqual(output, expected)
Beispiel #17
0
def prep_files(paths, extensions):
    """Parses `paths` (which may consist of files and/or directories).
    Removes duplicates, sorts, and returns verified srt files."""

    from batchpath import GeneratePaths

    filenames = GeneratePaths().files(paths, os.W_OK, extensions, 0, True)

    if filenames:
        return filenames
    else:
        LOGGER.error('No valid targets were specified')
        sys.exit(1)
    def test_nonrecursive(self):
        paths = ['content/.DirectoryA/SubdirA', 'content/DirectoryE/SubdirA']
        basenames = [
            'content/.DirectoryA/SubdirA/emptyfileA',
            'content/.DirectoryA/SubdirA/emptyfileB',
            'content/.DirectoryA/SubdirA/emptyfileC',
            'content/.DirectoryA/SubdirA/nonemptyA',
            'content/.DirectoryA/SubdirA/nonemptyB',
            'content/.DirectoryA/SubdirA/nonemptyC',
            'content/DirectoryE/SubdirA/emptyfileA',
            'content/DirectoryE/SubdirA/emptyfileB',
            'content/DirectoryE/SubdirA/emptyfileC',
            'content/DirectoryE/SubdirA/nonemptyA',
            'content/DirectoryE/SubdirA/nonemptyB',
            'content/DirectoryE/SubdirA/nonemptyC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.files(paths)

        self.assertEqual(output, expected)
    def test_recursion(self):
        paths = ['content']
        basenames = ['content/-DirectoryB',
                     'content/.DirectoryA',
                     'content/DirectoryD\\n',
                     'content/DirectoryE',
                     'content/DirectoryF',
                     'content/\\nDirectoryC',
                     'content/.DirectoryA/SubdirA',
                     'content/.DirectoryA/SubdirB',
                     'content/.DirectoryA/SubdirC',
                     'content/DirectoryD\\n/SubdirA',
                     'content/DirectoryD\\n/SubdirB',
                     'content/DirectoryD\\n/SubdirC',
                     'content/DirectoryE/SubdirA',
                     'content/DirectoryE/SubdirB',
                     'content/DirectoryE/SubdirC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.dirs(paths, recursion=True)

        self.assertEqual(output, expected)
Beispiel #20
0
    def test_recursion(self):
        paths = ['content']
        basenames = [
            'content/-DirectoryB', 'content/.DirectoryA',
            'content/DirectoryD\\n', 'content/DirectoryE',
            'content/DirectoryF', 'content/\\nDirectoryC', 'content/file1.txt',
            'content/file2_nonempty.txt', 'content/file3.conf',
            'content/.DirectoryA/SubdirA', 'content/.DirectoryA/SubdirB',
            'content/.DirectoryA/SubdirC',
            'content/.DirectoryA/SubdirA/emptyfileA',
            'content/.DirectoryA/SubdirA/emptyfileB',
            'content/.DirectoryA/SubdirA/emptyfileC',
            'content/.DirectoryA/SubdirA/nonemptyA',
            'content/.DirectoryA/SubdirA/nonemptyB',
            'content/.DirectoryA/SubdirA/nonemptyC',
            'content/.DirectoryA/SubdirB/emptyA',
            'content/.DirectoryA/SubdirB/emptyB',
            'content/.DirectoryA/SubdirB/emptyC',
            'content/.DirectoryA/SubdirB/empty_rootA',
            'content/.DirectoryA/SubdirB/empty_rootB',
            'content/.DirectoryA/SubdirB/empty_rootC',
            'content/.DirectoryA/SubdirB/nonemptyA',
            'content/.DirectoryA/SubdirB/nonemptyB',
            'content/.DirectoryA/SubdirB/nonemptyC',
            'content/.DirectoryA/SubdirB/nonempty_rootA',
            'content/.DirectoryA/SubdirB/nonempty_rootB',
            'content/.DirectoryA/SubdirB/nonempty_rootC',
            'content/DirectoryD\\n/SubdirA', 'content/DirectoryD\\n/SubdirB',
            'content/DirectoryD\\n/SubdirC',
            'content/DirectoryD\\n/SubdirA/emptyfileA',
            'content/DirectoryD\\n/SubdirA/emptyfileB',
            'content/DirectoryD\\n/SubdirA/emptyfileC',
            'content/DirectoryD\\n/SubdirA/nonemptyA',
            'content/DirectoryD\\n/SubdirA/nonemptyB',
            'content/DirectoryD\\n/SubdirA/nonemptyC',
            'content/DirectoryD\\n/SubdirB/emptyA',
            'content/DirectoryD\\n/SubdirB/emptyB',
            'content/DirectoryD\\n/SubdirB/emptyC',
            'content/DirectoryD\\n/SubdirB/empty_rootA',
            'content/DirectoryD\\n/SubdirB/empty_rootB',
            'content/DirectoryD\\n/SubdirB/empty_rootC',
            'content/DirectoryD\\n/SubdirB/nonemptyA',
            'content/DirectoryD\\n/SubdirB/nonemptyB',
            'content/DirectoryD\\n/SubdirB/nonemptyC',
            'content/DirectoryD\\n/SubdirB/nonempty_rootA',
            'content/DirectoryD\\n/SubdirB/nonempty_rootB',
            'content/DirectoryD\\n/SubdirB/nonempty_rootC',
            'content/DirectoryE/SubdirA', 'content/DirectoryE/SubdirB',
            'content/DirectoryE/SubdirC',
            'content/DirectoryE/SubdirA/emptyfileA',
            'content/DirectoryE/SubdirA/emptyfileB',
            'content/DirectoryE/SubdirA/emptyfileC',
            'content/DirectoryE/SubdirA/nonemptyA',
            'content/DirectoryE/SubdirA/nonemptyB',
            'content/DirectoryE/SubdirA/nonemptyC',
            'content/DirectoryE/SubdirB/emptyA',
            'content/DirectoryE/SubdirB/emptyB',
            'content/DirectoryE/SubdirB/emptyC',
            'content/DirectoryE/SubdirB/empty_rootA',
            'content/DirectoryE/SubdirB/empty_rootB',
            'content/DirectoryE/SubdirB/empty_rootC',
            'content/DirectoryE/SubdirB/nonemptyA',
            'content/DirectoryE/SubdirB/nonemptyB',
            'content/DirectoryE/SubdirB/nonemptyC',
            'content/DirectoryE/SubdirB/nonempty_rootA',
            'content/DirectoryE/SubdirB/nonempty_rootB',
            'content/DirectoryE/SubdirB/nonempty_rootC'
        ]

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.all(paths, recursion=True)

        self.assertEqual(output, expected)
    def test_recursion(self):
        paths = ['content']
        basenames = ['content/-DirectoryB',
                     'content/.DirectoryA',
                     'content/DirectoryD\\n',
                     'content/DirectoryE',
                     'content/DirectoryF',
                     'content/\\nDirectoryC',
                     'content/file1.txt',
                     'content/file2_nonempty.txt',
                     'content/file3.conf',
                     'content/.DirectoryA/SubdirA',
                     'content/.DirectoryA/SubdirB',
                     'content/.DirectoryA/SubdirC',
                     'content/.DirectoryA/SubdirA/emptyfileA',
                     'content/.DirectoryA/SubdirA/emptyfileB',
                     'content/.DirectoryA/SubdirA/emptyfileC',
                     'content/.DirectoryA/SubdirA/nonemptyA',
                     'content/.DirectoryA/SubdirA/nonemptyB',
                     'content/.DirectoryA/SubdirA/nonemptyC',
                     'content/.DirectoryA/SubdirB/emptyA',
                     'content/.DirectoryA/SubdirB/emptyB',
                     'content/.DirectoryA/SubdirB/emptyC',
                     'content/.DirectoryA/SubdirB/empty_rootA',
                     'content/.DirectoryA/SubdirB/empty_rootB',
                     'content/.DirectoryA/SubdirB/empty_rootC',
                     'content/.DirectoryA/SubdirB/nonemptyA',
                     'content/.DirectoryA/SubdirB/nonemptyB',
                     'content/.DirectoryA/SubdirB/nonemptyC',
                     'content/.DirectoryA/SubdirB/nonempty_rootA',
                     'content/.DirectoryA/SubdirB/nonempty_rootB',
                     'content/.DirectoryA/SubdirB/nonempty_rootC',
                     'content/DirectoryD\\n/SubdirA',
                     'content/DirectoryD\\n/SubdirB',
                     'content/DirectoryD\\n/SubdirC',
                     'content/DirectoryD\\n/SubdirA/emptyfileA',
                     'content/DirectoryD\\n/SubdirA/emptyfileB',
                     'content/DirectoryD\\n/SubdirA/emptyfileC',
                     'content/DirectoryD\\n/SubdirA/nonemptyA',
                     'content/DirectoryD\\n/SubdirA/nonemptyB',
                     'content/DirectoryD\\n/SubdirA/nonemptyC',
                     'content/DirectoryD\\n/SubdirB/emptyA',
                     'content/DirectoryD\\n/SubdirB/emptyB',
                     'content/DirectoryD\\n/SubdirB/emptyC',
                     'content/DirectoryD\\n/SubdirB/empty_rootA',
                     'content/DirectoryD\\n/SubdirB/empty_rootB',
                     'content/DirectoryD\\n/SubdirB/empty_rootC',
                     'content/DirectoryD\\n/SubdirB/nonemptyA',
                     'content/DirectoryD\\n/SubdirB/nonemptyB',
                     'content/DirectoryD\\n/SubdirB/nonemptyC',
                     'content/DirectoryD\\n/SubdirB/nonempty_rootA',
                     'content/DirectoryD\\n/SubdirB/nonempty_rootB',
                     'content/DirectoryD\\n/SubdirB/nonempty_rootC',
                     'content/DirectoryE/SubdirA',
                     'content/DirectoryE/SubdirB',
                     'content/DirectoryE/SubdirC',
                     'content/DirectoryE/SubdirA/emptyfileA',
                     'content/DirectoryE/SubdirA/emptyfileB',
                     'content/DirectoryE/SubdirA/emptyfileC',
                     'content/DirectoryE/SubdirA/nonemptyA',
                     'content/DirectoryE/SubdirA/nonemptyB',
                     'content/DirectoryE/SubdirA/nonemptyC',
                     'content/DirectoryE/SubdirB/emptyA',
                     'content/DirectoryE/SubdirB/emptyB',
                     'content/DirectoryE/SubdirB/emptyC',
                     'content/DirectoryE/SubdirB/empty_rootA',
                     'content/DirectoryE/SubdirB/empty_rootB',
                     'content/DirectoryE/SubdirB/empty_rootC',
                     'content/DirectoryE/SubdirB/nonemptyA',
                     'content/DirectoryE/SubdirB/nonemptyB',
                     'content/DirectoryE/SubdirB/nonemptyC',
                     'content/DirectoryE/SubdirB/nonempty_rootA',
                     'content/DirectoryE/SubdirB/nonempty_rootB',
                     'content/DirectoryE/SubdirB/nonempty_rootC']

        expected = [os.path.abspath(p) for p in basenames]

        gp = GeneratePaths()
        output = gp.all(paths, recursion=True)

        self.assertEqual(output, expected)