Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ignore_substring():
path = os.path.join(os.getcwd(),'tests','tests_file_io')
assert(find_files(substring='test_find_files', path=path, ignore_substring='test_find') == [])
def test_find_files():
path = os.path.join(os.getcwd(),'tests','tests_file_io')
expect = [os.path.join(os.getcwd(),'tests','tests_file_io', 'test_find_files.py')]
assert(find_files(substring='test_find_files', path=path) == expect)
# find recursive
assert(find_files(substring='test_find_files.py', path=os.getcwd(), recursive=True) == expect)
# find files and check extension
assert(find_files(substring='test_find_files.py', path=path, check_ext='.py') == expect)
assert(find_files(substring='test_find_files.py', path=path, check_ext='.txt') == [])
def test_find_files():
path = os.path.join(os.getcwd(),'tests','tests_file_io')
expect = [os.path.join(os.getcwd(),'tests','tests_file_io', 'test_find_files.py')]
assert(find_files(substring='test_find_files', path=path) == expect)
# find recursive
assert(find_files(substring='test_find_files.py', path=os.getcwd(), recursive=True) == expect)
# find files and check extension
assert(find_files(substring='test_find_files.py', path=path, check_ext='.py') == expect)
assert(find_files(substring='test_find_files.py', path=path, check_ext='.txt') == [])
def test_find_files():
path = os.path.join(os.getcwd(),'tests','tests_file_io')
expect = [os.path.join(os.getcwd(),'tests','tests_file_io', 'test_find_files.py')]
assert(find_files(substring='test_find_files', path=path) == expect)
# find recursive
assert(find_files(substring='test_find_files.py', path=os.getcwd(), recursive=True) == expect)
# find files and check extension
assert(find_files(substring='test_find_files.py', path=path, check_ext='.py') == expect)
assert(find_files(substring='test_find_files.py', path=path, check_ext='.txt') == [])
"""
n = len(paths)
# must have same number of paths and extensions
assert(len(paths) >= 2)
if extensions:
assert(len(extensions) == n)
else:
extensions = ['' for i in range(n)]
base = find_files(path=paths[0],
substring=substring,
check_ext=extensions[0],
ignore_invisible=ignore_invisible,
ignore_substring=ignore_substring)
rest = [find_files(path=paths[i],
substring=substring,
check_ext=extensions[i],
ignore_invisible=ignore_invisible,
ignore_substring=ignore_substring) for i in range(1, n)]
groups = {}
for f in base:
basename = os.path.splitext(os.path.basename(f))[0]
basename = re.sub('\%s$' % rstrip, '', basename)
groups[basename] = [f]
# groups = {os.path.splitext(os.path.basename(f))[0].rstrip(rstrip):[f]
# for f in base}
for idx, r in enumerate(rest):
for f in r:
Examples
-----------
For usage examples, please see
http://rasbt.github.io/mlxtend/user_guide/file_io/find_filegroups/
"""
n = len(paths)
# must have same number of paths and extensions
assert(len(paths) >= 2)
if extensions:
assert(len(extensions) == n)
else:
extensions = ['' for i in range(n)]
base = find_files(path=paths[0],
substring=substring,
check_ext=extensions[0],
ignore_invisible=ignore_invisible,
ignore_substring=ignore_substring)
rest = [find_files(path=paths[i],
substring=substring,
check_ext=extensions[i],
ignore_invisible=ignore_invisible,
ignore_substring=ignore_substring) for i in range(1, n)]
groups = {}
for f in base:
basename = os.path.splitext(os.path.basename(f))[0]
basename = re.sub('\%s$' % rstrip, '', basename)
groups[basename] = [f]