How to use the pathspec.pattern.RegexPattern 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 cpburnz / python-path-specification / pathspec / patterns / View on Github external
from __future__ import unicode_literals

import re
import warnings

from .. import util
from ..compat import unicode
from ..pattern import RegexPattern

#: The encoding to use when parsing a byte string pattern.
_BYTES_ENCODING = 'latin1'

class GitWildMatchPattern(RegexPattern):
	The :class:`GitWildMatchPattern` class represents a compiled Git
	wildmatch pattern.

	# Keep the dict-less class hierarchy.
	__slots__ = ()

	def pattern_to_regex(cls, pattern):
		Convert the pattern into a regular expression.

		*pattern* (:class:`unicode` or :class:`bytes`) is the pattern to
		convert into a regular expression.
github cpburnz / python-path-specification / pathspec / View on Github external
regex = re.compile(regex)

		elif pattern is not None and hasattr(pattern, 'match'):
			# Assume pattern is a precompiled regular expression.
			# - NOTE: Used specified *include*.
			regex = pattern

		elif pattern is None:
			# NOTE: Make sure to allow a null pattern to be passed for a
			# null-operation.
			assert include is None, "include:{!r} must be null when pattern:{!r} is null.".format(include, pattern)

			raise TypeError("pattern:{!r} is not a string, RegexObject, or None.".format(pattern))

		super(RegexPattern, self).__init__(include)
		self.regex = regex
github cpburnz / python-path-specification / pathspec / View on Github external
def __eq__(self, other):
		Tests the equality of this regex pattern with *other* (:class:`RegexPattern`)
		by comparing their :attr:`~Pattern.include` and :attr:`~RegexPattern.regex`
		if isinstance(other, RegexPattern):
			return self.include == other.include and self.regex == other.regex
			return NotImplemented