input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _testrefastpath(repat): """Test if a re pattern can use fast path. That is, for every "$A/$B" path the pattern matches, "$A" must also be matched, Return True if we're sure it is. Return False otherwise. """ # XXX: It's very hard to implement this. These are what need to be # supported...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _run(): while _updating: update()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _globpatsplit(pat): """Split a glob pattern. Return a list. A naive version is "path.split("/")". This function handles more cases, like "{*,{a,b}*/*}". >>> _globpatsplit("*/**/x/{a,b/c}") ['*', '**', 'x', '{a,b/c}'] """ result = [] buf = "" parentheses = 0 for ch in pat: ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def update_off(): global _updating _updating = False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, *args, **kwargs): # If True, avoid entering subdirectories, and match everything recursively, # unconditionally. self.matchrecursive = False # If True, avoid entering subdirectories, and return "unsure" for # everything. This is set to True when complex re patt...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def loopcv(): import cv while 1: cv.ShowImage('hi',get_depth().astype(np.uint8)) cv.WaitKey(10)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def insert(self, path, matchrecursive=True, globpats=None, repats=None): """Insert a directory path to this tree. If matchrecursive is True, mark the directory as unconditionally include files and subdirs recursively. If globpats or repats are specified, append them to the patterns bei...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, path): """Similar to matcher.visitdir""" path = normalizerootdir(path, "visitdir") if self.matchrecursive: return "all" elif self.unsurerecursive: return True elif path == "": return True if self._kindpats and self._...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _compiledpats(self): pat, matchfunc = _buildregexmatch(self._kindpats, "") return matchfunc
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _compileddirpats(self): pat, matchfunc = _buildregexmatch( [("glob", p, "") for p in self._globdirpats], "$" ) return matchfunc
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _split(self, path): if "/" in path: subdir, rest = path.split("/", 1) else: subdir, rest = path, "" if not subdir: raise error.ProgrammingError("path cannot be absolute") return subdir, rest
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _remainingpats(pat, prefix): """list of patterns with prefix stripped >>> _remainingpats("a/b/c", "") ['a/b/c'] >>> _remainingpats("a/b/c", "a") ['b/c'] >>> _remainingpats("a/b/c", "a/b") ['c'] >>> _remainingpats("a/b/c", "a/b/c") [] >>> _remainingpats("", "") [] """...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _buildvisitdir(kindpats): """Try to build an efficient visitdir function Return a visitdir function if it's built. Otherwise return None if there are unsupported patterns. >>> _buildvisitdir([('include', 'foo', '')]) >>> _buildvisitdir([('relglob', 'foo', '')]) >>> t = _buildvisitdir([ ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, badfn=None, relativeuipath=True): self._root = root self._cwd = cwd if badfn is not None: self.bad = badfn self._relativeuipath = relativeuipath
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<%s>" % self.__class__.__name__
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __call__(self, fn): return self.matchfn(fn)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __iter__(self): for f in self._files: yield f
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def bad(self, f, msg): """Callback from dirstate.walk for each explicit file that can't be found/accessed, with an error message."""
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def abs(self, f): """Convert a repo path back to path that is relative to the root of the matcher.""" return f
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def rel(self, f): """Convert repo path back to path that is relative to cwd of matcher.""" return util.pathto(self._root, self._cwd, f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def uipath(self, f): """Convert repo path to a display path. If patterns or -I/-X were used to create this matcher, the display path will be relative to cwd. Otherwise it is relative to the root of the repo.""" return (self._relativeuipath and self.rel(f)) or self.abs(f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def files(self): """Explicitly listed files or patterns or roots: if no patterns or .always(): empty list, if exact: list exact files, if not .anypats(): list all files and dirs, else: optimal roots""" return self._files
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _fileset(self): return set(self._files)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def exact(self, f): """Returns True if f is in .files().""" return f in self._fileset
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): """Decides whether a directory should be visited based on whether it has potential matches in it or one of its subdirectories. This is based on the match's primary, included, and excluded patterns. Returns the string 'all' if the given directory and all subdirec...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def always(self): """Matcher will match everything and .files() will be empty -- optimization might be possible.""" return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def isexact(self): """Matcher will match exactly the list of files in .files() -- optimization might be possible.""" return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def prefix(self): """Matcher will match the paths in .files() recursively -- optimization might be possible.""" return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def anypats(self): """None of .always(), .isexact(), and .prefix() is true -- optimizations will be difficult.""" return not self.always() and not self.isexact() and not self.prefix()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, badfn=None, relativeuipath=False): super(alwaysmatcher, self).__init__( root, cwd, badfn, relativeuipath=relativeuipath )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def always(self): return True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): return "all"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<alwaysmatcher>"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, badfn=None): super(nevermatcher, self).__init__(root, cwd, badfn)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def isexact(self): return True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<nevermatcher>"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, badfn=None, gitignorepaths=None): super(gitignorematcher, self).__init__(root, cwd, badfn) gitignorepaths = gitignorepaths or [] self._matcher = pathmatcher.gitignorematcher(root, gitignorepaths)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): # XXX: is_dir is set to True here for performance. # It should be set to whether "f" is actually a directory or not. return self._matcher.match_relative(f, True)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def explain(self, f): return self._matcher.explain(f, True)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") matched = self._matcher.match_relative(dir, True) if matched: # Everything in the directory is selected (ignored) return "all" else: # Not sure return True
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<gitignorematcher>"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, badfn=None, rules=[]): super(treematcher, self).__init__(root, cwd, badfn) rules = list(rules) self._matcher = pathmatcher.treematcher(rules) self._rules = rules
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return self._matcher.matches(f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): matched = self._matcher.match_recursive(dir) if matched is None: return True elif matched is True: return "all" else: assert matched is False return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<treematcher rules=%r>" % self._rules
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def normalizerootdir(dir, funcname): if dir == ".": util.nouideprecwarn( "match.%s() no longer accepts '.', use '' instead." % funcname, "20190805" ) return "" return dir
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _kindpatstoglobs(kindpats, recursive=False): """Attempt to convert 'kindpats' to glob patterns that can be used in a treematcher. kindpats should be already normalized to be relative to repo root. If recursive is True, `glob:a*` will match both `a1/b` and `a1`, otherwise `glob:a*` will only ma...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _makeglobrecursive(pat): """Make a glob pattern recursive by appending "/**" to it""" if pat.endswith("/") or not pat: return pat + "**" else: return pat + "/**"
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _convertretoglobs(repat): """Attempt to convert a regular expression pattern to glob patterns. A single regular expression pattern might be converted into multiple glob patterns. Return None if conversion is unsupported. >>> _convertretoglobs("abc*") is None True >>> _convertretoglobs...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, kindpats, ctx=None, badfn=None): super(patternmatcher, self).__init__(root, cwd, badfn) # kindpats are already normalized to be relative to repo-root. # Can we use tree matcher? rules = _kindpatstoglobs(kindpats, recursive=False) fallback = True ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _dirs(self): return set(util.dirs(self._fileset))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if self._prefix and dir in self._fileset: return "all" if not self._prefix: return True return ( dir in self._fileset or dir in self._dirs or any(parentdir in self...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def prefix(self): return self._prefix
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<patternmatcher patterns=%r>" % self._pats
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, kindpats, ctx=None, badfn=None): super(includematcher, self).__init__(root, cwd, badfn) # Can we use tree matcher? rules = _kindpatstoglobs(kindpats, recursive=True) fallback = True if rules is not None: try: matcher = tr...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if self._prefix and dir in self._roots: return "all" return ( dir in self._roots or dir in self._dirs or any(parentdir in self._roots for parentdir in util.finddirs(dir)) )
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<includematcher includes=%r>" % self._pats
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, root, cwd, files, badfn=None): super(exactmatcher, self).__init__(root, cwd, badfn) if isinstance(files, list): self._files = files else: self._files = list(files)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") return dir in self._dirs
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<exactmatcher files=%r>" % self._files
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, m1, m2): super(differencematcher, self).__init__(m1._root, m1._cwd) self._m1 = m1 self._m2 = m2 self.bad = m1.bad self.traversedir = m1.traversedir
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return self._m1(f) and (not self._m2(f) or self._m1.exact(f))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _files(self): if self.isexact(): return [f for f in self._m1.files() if self(f)] # If m1 is not an exact matcher, we can't easily figure out the set of # files, because its files() are not always files. For example, if # m1 is "path:dir" and m2 is "rootfileins:.", we don'...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if not self._m2.visitdir(dir): return self._m1.visitdir(dir) if self._m2.visitdir(dir) == "all": # There's a bug here: If m1 matches file 'dir/file' and m2 excludes # 'dir' (recursively), we sho...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def isexact(self): return self._m1.isexact()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<differencematcher m1=%r, m2=%r>" % (self._m1, self._m2)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def intersectmatchers(m1, m2): """Composes two matchers by matching if both of them match. The second matcher's non-matching-attributes (root, cwd, bad, traversedir) are ignored. """ if m1 is None or m2 is None: return m1 or m2 if m1.always(): m = copy.copy(m2) # TODO: C...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, m1, m2): super(intersectionmatcher, self).__init__(m1._root, m1._cwd) self._m1 = m1 self._m2 = m2 self.bad = m1.bad self.traversedir = m1.traversedir
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def _files(self): if self.isexact(): m1, m2 = self._m1, self._m2 if not m1.isexact(): m1, m2 = m2, m1 return [f for f in m1.files() if m2(f)] # It neither m1 nor m2 is an exact matcher, we can't easily intersect # the set of files, because thei...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return self._m1(f) and self._m2(f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") visit1 = self._m1.visitdir(dir) if visit1 == "all": return self._m2.visitdir(dir) # bool() because visit1=True + visit2='all' should not be 'all' return bool(visit1 and self._m2.visitdir(dir))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def always(self): return self._m1.always() and self._m2.always()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def isexact(self): return self._m1.isexact() or self._m2.isexact()
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<intersectionmatcher m1=%r, m2=%r>" % (self._m1, self._m2)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, path, matcher): super(subdirmatcher, self).__init__(matcher._root, matcher._cwd) self._path = path self._matcher = matcher self._always = matcher.always() self._files = [ f[len(path) + 1 :] for f in matcher._files if f.startswith(path + "/") ...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def bad(self, f, msg): self._matcher.bad(self._path + "/" + f, msg)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def abs(self, f): return self._matcher.abs(self._path + "/" + f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def rel(self, f): return self._matcher.rel(self._path + "/" + f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def uipath(self, f): return self._matcher.uipath(self._path + "/" + f)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): # Some information is lost in the superclass's constructor, so we # can not accurately create the matching function for the subdirectory # from the inputs. Instead, we override matchfn() and visitdir() to # call the original matcher with the subdirectory path prepen...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if dir == "": dir = self._path else: dir = self._path + "/" + dir return self._matcher.visitdir(dir)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def always(self): return self._always
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def prefix(self): return self._matcher.prefix() and not self._always
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<subdirmatcher path=%r, matcher=%r>" % (self._path, self._matcher)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, matchers): m1 = matchers[0] super(unionmatcher, self).__init__(m1._root, m1._cwd) self.traversedir = m1.traversedir self._matchers = matchers
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): for match in self._matchers: if match(f): return True return False
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): r = False for m in self._matchers: v = m.visitdir(dir) if v == "all": return v r |= v return r
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<unionmatcher matchers=%r>" % self._matchers
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, m1, m2): super(xormatcher, self).__init__(m1._root, m1._cwd) self.traversedir = m1.traversedir self.m1 = m1 self.m2 = m2
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): return bool(self.m1(f)) ^ bool(self.m2(f))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): m1dir = self.m1.visitdir(dir) m2dir = self.m2.visitdir(dir) # if both matchers return "all" then we know for sure we don't need # to visit this directory. Same if all matchers return False. In all # other case we have to visit a directory. if m1d...
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<xormatcher matchers=%r>" % self._matchers
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __init__(self, matcher): self._matcher = matcher
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def matchfn(self, f): match = self._matcher return match(f) or any(map(match, util.dirs((f,))))
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def visitdir(self, dir): if self(dir): return "all" return self._matcher.visitdir(dir)
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def __repr__(self): return "<recursivematcher %r>" % self._matcher
def dist(a, b): return sum((i-j)**2 for i, j in zip(a, b))
def patkind(pattern, default=None): """If pattern is 'kind:pat' with a known kind, return kind.""" return _patsplit(pattern, default)[0]