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_unglobbed_prefix(self):
assert glob.unglobbed_prefix('a/b/c*/d') == 'a/b'
assert glob.unglobbed_prefix('a/b/**/d') == 'a/b'
assert glob.unglobbed_prefix('/a/b/*/d') == '/a/b'
assert glob.unglobbed_prefix('*/a/b') == ''
def test_unglobbed_prefix(self):
assert glob.unglobbed_prefix('a/b/c*/d') == 'a/b'
assert glob.unglobbed_prefix('a/b/**/d') == 'a/b'
assert glob.unglobbed_prefix('/a/b/*/d') == '/a/b'
assert glob.unglobbed_prefix('*/a/b') == ''
def test_unglobbed_prefix(self):
assert glob.unglobbed_prefix('a/b/c*/d') == 'a/b'
assert glob.unglobbed_prefix('a/b/**/d') == 'a/b'
assert glob.unglobbed_prefix('/a/b/*/d') == '/a/b'
assert glob.unglobbed_prefix('*/a/b') == ''
def test_unglobbed_prefix(self):
assert glob.unglobbed_prefix('a/b/c*/d') == 'a/b'
assert glob.unglobbed_prefix('a/b/**/d') == 'a/b'
assert glob.unglobbed_prefix('/a/b/*/d') == '/a/b'
assert glob.unglobbed_prefix('*/a/b') == ''
async def _get_glob_entries(_cache, tree, globs_list):
matches = {}
for glob_str in globs_list:
# Do an in-memory match of all the paths in the tree against the
# glob expression. As an optimization, if the glob is something
# like 'a/b/**/foo', only list the paths under 'a/b'.
regex = glob.glob_to_path_regex(glob_str)
prefix = glob.unglobbed_prefix(glob_str)
entries = await _cache.ls_tree(tree, prefix, recursive=True)
found = False
for path, entry in entries.items():
if re.match(regex, path):
matches[path] = entry
found = True
if not found:
raise NoMatchingFilesError(
'"{}" didn\'t match any files.'.format(glob_str))
return matches