How to use the peru.glob.unglobbed_prefix function in peru

To help you get started, we’ve selected a few peru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buildinspace / peru / tests / test_glob.py View on Github external
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') == ''
github buildinspace / peru / tests / test_glob.py View on Github external
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') == ''
github buildinspace / peru / tests / test_glob.py View on Github external
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') == ''
github buildinspace / peru / tests / test_glob.py View on Github external
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') == ''
github buildinspace / peru / peru / rule.py View on Github external
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