MCPcopy Index your code
hub / github.com/borgbackup/borg / match

Method match

src/borg/patterns.py:138–163  ·  view source on GitHub ↗

Return True or False depending on whether *path* is matched. If no match is found among the patterns in this matcher, then the value in self.fallback is returned (defaults to None).

(self, path)

Source from the content-addressed store, hash-verified

136 self._add(pattern, cmd)
137
138 def match(self, path):
139 """Return True or False depending on whether *path* is matched.
140
141 If no match is found among the patterns in this matcher, then the value
142 in self.fallback is returned (defaults to None).
143
144 """
145 path = normalize_path(path).lstrip("/")
146 # do a fast lookup for full path matches (note: we do not count such matches):
147 non_existent = object()
148 value = self._path_full_patterns.get(path, non_existent)
149
150 if value is not non_existent:
151 # we have a full path match!
152 self.recurse_dir = command_recurses_dir(value)
153 return self.is_include_cmd[value]
154
155 # this is the slow way, if we have many patterns in self._items:
156 for pattern, cmd in self._items:
157 if pattern.match(path, normalize=False):
158 self.recurse_dir = pattern.recurse_dir
159 return self.is_include_cmd[cmd]
160
161 # by default we will recurse if there is no match
162 self.recurse_dir = self.recurse_dir_default
163 return self.fallback
164
165
166def normalize_path(path):

Callers 2

evaluateFunction · 0.95
test_pattern_matcherFunction · 0.95

Calls 4

normalize_pathFunction · 0.85
command_recurses_dirFunction · 0.85
getMethod · 0.45
matchMethod · 0.45

Tested by 2

evaluateFunction · 0.76
test_pattern_matcherFunction · 0.76