This file is indexed.

/usr/lib/python3/dist-packages/pathspec/pattern.py is in python3-pathspec 0.3.4-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# encoding: utf-8
"""
This module provides the base definition for patterns.
"""

import re

from .compat import string_types


class Pattern(object):
	"""
	The ``Pattern`` class is the abstract definition of a pattern.
	"""

	# Make the class dict-less.
	__slots__ = ('include',)

	def __init__(self, include):
		"""
		Initializes the ``Pattern`` instance.

		*include* (``bool``) is whether the matched files should be included
		(``True``), excluded (``False``), or is a null-operation (``None``).
		"""

		self.include = include
		"""
		*include* (``bool``) is whether the matched files should be included
		(``True``), excluded (``False``), or is a null-operation (``None``).
		"""

	def match(self, files):
		"""
		Matches this pattern against the specified files.

		*files* (``Iterable``) contains each file (``str``) relative to the
		root directory (e.g., "relative/path/to/file").

		Returns an ``Iterable`` yielding each matched file path (``str``).
		"""
		raise NotImplementedError("{}.{} must override match().".format(self.__class__.__module__, self.__class__.__name__))


class RegexPattern(Pattern):
	"""
	The ``RegexPattern`` class is an implementation of a pattern using
	regular expressions.
	"""

	# Make the class dict-less.
	__slots__ = ('regex',)

	def __init__(self, regex, *args, **kw):
		"""
		Initializes the ``RegexPattern`` instance.

		*regex* (``RegexObject`` or ``str``) is the regular expression for
		the pattern.

		`*args` are positional arguments to send to the ``Pattern``
		constructor.

		`**kw` are keyword arguments to send to the ``Pattern`` constructor.
		"""

		self.regex = None
		"""
		*regex* (``RegexObject``) is the regular expression for the pattern.
		"""

		# NOTE: Make sure to allow a null regex pattern to be passed for a
		# null-operation.
		if isinstance(regex, string_types):
			regex = re.compile(regex)

		super(RegexPattern, self).__init__(*args, **kw)

		self.regex = regex

	def match(self, files):
		"""
		Matches this pattern against the specified files.

		*files* (``Iterable``) contains each file (``str``) relative to the
		root directory (e.g., "relative/path/to/file").

		Returns an ``Iterable`` yielding each matched file path (``str``).
		"""
		if self.include is not None:
			for path in files:
				if self.regex.match(path) is not None:
					yield path