How to use the pathspec.pathspec.PathSpec 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 pantsbuild / pants / src / python / pants / base / project_tree.py View on Github external
def __init__(self, build_root, ignore_patterns=None):
    if not os.path.isabs(build_root):
      raise self.InvalidBuildRootError(
          'ProjectTree build_root {} must be an absolute path.'.format(build_root))
    self.build_root = os.path.realpath(build_root)
    logger.debug('ProjectTree ignore_patterns: %s', ignore_patterns)
    self.ignore_patterns = ignore_patterns if ignore_patterns else []
    self.ignore = PathSpec.from_lines(GitWildMatchPattern, self.ignore_patterns)
github nzoschke / gofaas / vendor / pip / yamllint / config.py 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'):
                continue
github adrienverge / yamllint / yamllint / config.py View on Github external
def validate_rule_conf(rule, conf):
    if conf is False:  # disable
        return False

    if isinstance(conf, dict):
        if ('ignore' in conf and
                not isinstance(conf['ignore'], pathspec.pathspec.PathSpec)):
            if not isinstance(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', {})
        options_default = getattr(rule, 'DEFAULT', {})
        for optkey in conf:
            if optkey in ('ignore', 'level'):
github cpburnz / python-path-specification / pathspec / pathspec.py View on Github external
def __eq__(self, other):
		"""
		Tests the equality of this path-spec with *other* (:class:`PathSpec`)
		by comparing their :attr:`~PathSpec.patterns` attributes.
		"""
		if isinstance(other, PathSpec):
			paired_patterns = izip_longest(self.patterns, other.patterns)
			return all(a == b for a, b in paired_patterns)
		else:
			return NotImplemented