How to use the pathspec.PathSpec.from_lines function in pathspec

To help you get started, we’ve selected a few pathspec 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 psf / black / tests / View on Github external
def test_empty_exclude(self) -> None:
        path = THIS_DIR / "data" / "include_exclude_tests"
        report = black.Report()
        gitignore = PathSpec.from_lines("gitwildmatch", [])
        empty = re.compile(r"")
        sources: List[Path] = []
        expected = [
            Path(path / "b/dont_exclude/"),
            Path(path / "b/dont_exclude/a.pyi"),
            Path(path / "b/exclude/"),
            Path(path / "b/exclude/a.pyi"),
            Path(path / "b/.definitely_exclude/"),
            Path(path / "b/.definitely_exclude/a.pyi"),
        this_abs = THIS_DIR.resolve()
github nzoschke / gofaas / vendor / pip / yamllint / View on Github external
def validate_rule_conf(rule, conf):
    if conf is False or conf == 'disable':
        return False
    elif conf == 'enable':
        conf = {}

    if type(conf) == dict:
        if ('ignore' in conf and
                type(conf['ignore']) != pathspec.pathspec.PathSpec):
            if type(conf['ignore']) != str:
                raise YamlLintConfigError(
                    'invalid config: ignore should contain file patterns')
            conf['ignore'] = pathspec.PathSpec.from_lines(
                'gitwildmatch', conf['ignore'].splitlines())

        if 'level' not in conf:
            conf['level'] = 'error'
        elif conf['level'] not in ('error', 'warning'):
            raise YamlLintConfigError(
                'invalid config: level should be "error" or "warning"')

        options = getattr(rule, 'CONF', {})
        for optkey in conf:
            if optkey in ('ignore', 'level'):
            if optkey not in options:
                raise YamlLintConfigError(
                    'invalid config: unknown option "%s" for rule "%s"' %
                    (optkey, rule.ID))
github datawire / forge / forge / View on Github external
def descend(path, parent, ignores):
            if not os.path.exists(path): return
            ignores = ignores[:]

            ignores += get_ignores(path)
            spec = pathspec.PathSpec.from_lines('gitwildmatch', ignores)
            names = [n for n in os.listdir(path) if not spec.match_file(os.path.relpath(os.path.join(path, n),

            if "service.yaml" in names:
                candidate = os.path.join(path, "service.yaml")
                if is_service_descriptor(candidate):
                    svc = Service(self.forge, candidate, shallow=shallow)
                    if not in
              [] = svc
                    parent = svc

            if "Dockerfile" in names and parent:
                parent.dockerfiles.append(os.path.relpath(os.path.join(path, "Dockerfile"), parent.root))

            for n in names: