input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def exact(root, cwd, files, badfn=None): return exactmatcher(root, cwd, files, badfn=badfn)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def EVT_MOUSEWHEEL(event): global zoomdist dy = event.WheelRotation zoomdist *= np.power(0.95, -dy) refresh()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def always(root, cwd): return alwaysmatcher(root, cwd)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def mouse_rotate(xAngle, yAngle, zAngle): glRotatef(xAngle, 1.0, 0.0, 0.0); glRotatef(yAngle, 0.0, 1.0, 0.0); glRotatef(zAngle, 0.0, 0.0, 1.0);
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def never(root, cwd): return nevermatcher(root, cwd)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def playcolors(): while 1: global clearcolor clearcolor = [np.random.random(),0,0,0] time.sleep(0.1) refresh()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def union(matches, root, cwd): """Union a list of matchers. If the list is empty, return nevermatcher. If the list only contains one non-None value, return that matcher. Otherwise return a union matcher. """ matches = list(filter(None, matches)) if len(matches) == 0: return nevermatcher(root, cwd) elif len(matches) == 1: return matches[0] else: return unionmatcher(matches)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def update(dt=0): global projpts, rgb, depth depth,_ = freenect.sync_get_depth() rgb,_ = freenect.sync_get_video() q = depth X,Y = np.meshgrid(range(640),range(480)) # YOU CAN CHANGE THIS AND RERUN THE PROGRAM! # Point cloud downsampling d = 4 projpts = calibkinect.depth2xyzuv(q[::d,::d],X[::d,::d],Y[::d,::d]) refresh()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def badmatch(match, badfn): """Make a copy of the given matcher, replacing its bad method with the given one. """ m = copy.copy(match) m.bad = badfn return m
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def update_join(): update_on() try: _thread.join() except: update_off()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _donormalize(patterns, default, root, cwd, auditor, warn): """Convert 'kind:pat' from the patterns list to tuples with kind and normalized and rooted patterns and with listfiles expanded.""" kindpats = [] for kind, pat in [_patsplit(p, default) for p in patterns]: if kind in cwdrelativepatternkinds: pat = pathutil.canonpath(root, cwd, pat, auditor) elif kind in ("relglob", "path", "rootfilesin"): pat = util.normpath(pat) elif kind in ("listfile", "listfile0"): try: files = decodeutf8(util.readfile(pat)) if kind == "listfile0": files = files.split("\0") else: files = files.splitlines() files = [f for f in files if f] except EnvironmentError: raise error.Abort(_("unable to read file list (%s)") % pat) for k, p, source in _donormalize(files, default, root, cwd, auditor, warn): kindpats.append((k, p, pat)) continue elif kind == "include": try: fullpath = os.path.join(root, util.localpath(pat)) includepats = readpatternfile(fullpath, warn) for k, p, source in _donormalize( includepats, default, root, cwd, auditor, warn ): kindpats.append((k, p, source or pat)) except error.Abort as inst: raise error.Abort("%s: %s" % (pat, inst[0])) except IOError as inst: if warn: warn( _("skipping unreadable pattern file '%s': %s\n") % (pat, inst.strerror) ) continue # else: re or relre - which cannot be normalized kindpats.append((kind, pat, "")) return kindpats
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def update_on(): global _updating if not '_updating' in globals(): _updating = False if _updating: return
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 in production and tests. Very hacky. But we plan to get rid # of re matchers eventually. # Rules like "(?!experimental/)" if repat.startswith("(?!") and repat.endswith(")") and repat.count(")") == 1: return True # Rules used in doctest if repat == "(i|j)$": return True return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _run(): while _updating: update()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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: if ch == "{": parentheses += 1 elif ch == "}": parentheses -= 1 if parentheses == 0 and ch == "/": if buf: result.append(buf) buf = "" else: buf += ch if buf: result.append(buf) return result
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def update_off(): global _updating _updating = False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 patterns (potentially # including "/") are used. self.unsurerecursive = False # Patterns for matching paths in this directory. self._kindpats = [] # Glob patterns used to match parent directories of another glob # pattern. self._globdirpats = [] super(_tree, self).__init__(*args, **kwargs)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def loopcv(): import cv while 1: cv.ShowImage('hi',get_depth().astype(np.uint8)) cv.WaitKey(10)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 being applied at this directory. The tricky part is those patterns can match "x/y/z" and visit("x"), visit("x/y") need to return True, while we still want visit("x/a") to return False. """ if path == "": self.matchrecursive |= matchrecursive if globpats: # Need to match parent directories too. for pat in globpats: components = _globpatsplit(pat) parentpat = "" for comp in components: if parentpat: parentpat += "/" parentpat += comp if "/" in comp: # Giving up - fallback to slow paths. self.unsurerecursive = True self._globdirpats.append(parentpat) if any("**" in p for p in globpats): # Giving up - "**" matches paths including "/" self.unsurerecursive = True self._kindpats += [("glob", pat, "") for pat in globpats] if repats: if not all(map(_testrefastpath, repats)): # Giving up - fallback to slow paths. self.unsurerecursive = True self._kindpats += [("re", pat, "") for pat in repats] return subdir, rest = self._split(path) self.setdefault(subdir, _tree()).insert(rest, matchrecursive, globpats, repats)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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._compiledpats(path): # XXX: This is incorrect. But re patterns are already used in # production. We should kill them! # Need to test "if every string starting with 'path' matches". # Obviously it's impossible to test *every* string with the # standard regex API, therefore pick a random strange path to test # it approximately. if self._compiledpats("%s/*/_/-/0/*" % path): return "all" else: return True if self._globdirpats and self._compileddirpats(path): return True subdir, rest = self._split(path) subtree = self.get(subdir) if subtree is None: return False else: return subtree.visitdir(rest)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _compiledpats(self): pat, matchfunc = _buildregexmatch(self._kindpats, "") return matchfunc
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _compileddirpats(self): pat, matchfunc = _buildregexmatch( [("glob", p, "") for p in self._globdirpats], "$" ) return matchfunc
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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("", "") [] """ if prefix: if prefix == pat: return [] else: assert pat[len(prefix)] == "/" return [pat[len(prefix) + 1 :]] else: if pat: return [pat] else: return []
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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([ ... ('glob', 'a/b', ''), ... ('glob', 'c/*.d', ''), ... ('glob', 'e/**/*.c', ''), ... ('re', '^f/(?!g)', ''), # no "$", only match prefix ... ('re', '^h/(i|j)$', ''), ... ('glob', 'i/a*/b*/c*', ''), ... ('glob', 'i/a5/b7/d', ''), ... ('glob', 'j/**.c', ''), ... ]) >>> t('a') True >>> t('a/b') 'all' >>> t('a/b/c') 'all' >>> t('c') True >>> t('c/d') False >>> t('c/rc.d') 'all' >>> t('c/rc.d/foo') 'all' >>> t('e') True >>> t('e/a') True >>> t('e/a/b.c') True >>> t('e/a/b.d') True >>> t('f') True >>> t('f/g') False >>> t('f/g2') False >>> t('f/g/a') False >>> t('f/h') 'all' >>> t('f/h/i') 'all' >>> t('h/i') True >>> t('h/i/k') False >>> t('h/k') False >>> t('i') True >>> t('i/a1') True >>> t('i/b2') False >>> t('i/a/b2/c3') 'all' >>> t('i/a/b2/d4') False >>> t('i/a5/b7/d') 'all' >>> t('j/x/y') True >>> t('z') False """ tree = _tree() for kind, pat, _source in kindpats: if kind == "glob": components = [] for p in pat.split("/"): if "[" in p or "{" in p or "*" in p or "?" in p: break components.append(p) prefix = "/".join(components) matchrecursive = prefix == pat tree.insert( prefix, matchrecursive=matchrecursive, globpats=_remainingpats(pat, prefix), ) elif kind == "re": # Still try to get a plain prefix from the regular expression so we # can still have fast paths. if pat.startswith("^"): # "re" already matches from the beginning, unlike "relre" pat = pat[1:] components = [] for p in pat.split("/"): if re.escape(p) != p: # contains special characters break components.append(p) prefix = "/".join(components) tree.insert( prefix, matchrecursive=False, repats=_remainingpats(pat, prefix) ) else: # Unsupported kind return None return tree.visitdir
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<%s>" % self.__class__.__name__
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __call__(self, fn): return self.matchfn(fn)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __iter__(self): for f in self._files: yield f
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def bad(self, f, msg): """Callback from dirstate.walk for each explicit file that can't be found/accessed, with an error message."""
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def abs(self, f): """Convert a repo path back to path that is relative to the root of the matcher.""" return f
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _fileset(self): return set(self._files)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def exact(self, f): """Returns True if f is in .files().""" return f in self._fileset
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def matchfn(self, f): return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 subdirectories should be visited. Otherwise returns True or False indicating whether the given directory should be visited. """ return True
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def always(self): """Matcher will match everything and .files() will be empty -- optimization might be possible.""" return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def isexact(self): """Matcher will match exactly the list of files in .files() -- optimization might be possible.""" return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def prefix(self): """Matcher will match the paths in .files() recursively -- optimization might be possible.""" return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __init__(self, root, cwd, badfn=None, relativeuipath=False): super(alwaysmatcher, self).__init__( root, cwd, badfn, relativeuipath=relativeuipath )
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def always(self): return True
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def matchfn(self, f): return True
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def visitdir(self, dir): return "all"
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<alwaysmatcher>"
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __init__(self, root, cwd, badfn=None): super(nevermatcher, self).__init__(root, cwd, badfn)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def isexact(self): return True
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def visitdir(self, dir): return False
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<nevermatcher>"
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def explain(self, f): return self._matcher.explain(f, True)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<gitignorematcher>"
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def matchfn(self, f): return self._matcher.matches(f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<treematcher rules=%r>" % self._rules
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def normalizerootdir(dir, funcname): if dir == ".": util.nouideprecwarn( "match.%s() no longer accepts '.', use '' instead." % funcname, "20190805" ) return "" return dir
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 match `a1` but not `a1/b`. Return None if there are unsupported patterns (ex. regular expressions). """ if not _usetreematcher: return None globs = [] for kindpat in kindpats: kind, pat = kindpat[0:2] if kind == "re": # Attempt to convert the re pat to globs reglobs = _convertretoglobs(pat) if reglobs is not None: globs += reglobs else: return None elif kind == "glob": # The treematcher (man gitignore) does not support csh-style # brackets (ex. "{a,b,c}"). Expand the brackets to patterns. for subpat in pathmatcher.expandcurlybrackets(pat): normalized = pathmatcher.normalizeglob(subpat) if recursive: normalized = _makeglobrecursive(normalized) globs.append(normalized) elif kind == "path": if pat == ".": # Special case. Comes from `util.normpath`. pat = "" else: pat = pathmatcher.plaintoglob(pat) pat = _makeglobrecursive(pat) globs.append(pat) else: return None return globs
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _makeglobrecursive(pat): """Make a glob pattern recursive by appending "/**" to it""" if pat.endswith("/") or not pat: return pat + "**" else: return pat + "/**"
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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("xx/yy/(?!zz/kk)") ['xx/yy/**', '!xx/yy/zz/kk/**'] >>> _convertretoglobs("x/y/(?:.*/)?BUCK") ['x/y/**/BUCK'] """ m = _repat1.match(repat) if m: prefix, excluded = m.groups() return ["%s/**" % prefix, "!%s/%s/**" % (prefix, excluded)] m = _repat2.match(repat) if m: prefix, name = m.groups() return ["%s/**/%s" % (prefix, name)] return None
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 if rules is not None: try: matcher = treematcher(root, cwd, badfn=badfn, rules=rules) # Replace self to 'matcher'. self.__dict__ = matcher.__dict__ self.__class__ = matcher.__class__ fallback = False except ValueError: # for example, Regex("Compiled regex exceeds size limit of 10485760 bytes.") pass if fallback: self._prefix = _prefix(kindpats) self._pats, self.matchfn = _buildmatch(ctx, kindpats, "$", root) self._files = _explicitfiles(kindpats)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def _dirs(self): return set(util.dirs(self._fileset))
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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._fileset for parentdir in util.finddirs(dir)) )
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def prefix(self): return self._prefix
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<patternmatcher patterns=%r>" % self._pats
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 = treematcher(root, cwd, badfn=badfn, rules=rules) # Replace self to 'matcher'. self.__dict__ = matcher.__dict__ self.__class__ = matcher.__class__ fallback = False except ValueError: # for example, Regex("Compiled regex exceeds size limit of 10485760 bytes.") pass if fallback: self._pats, self.matchfn = _buildmatch(ctx, kindpats, "(?:/|$)", root) # prefix is True if all patterns are recursive, so certain fast paths # can be enabled. Unfortunately, it's too easy to break it (ex. by # using "glob:*.c", "re:...", etc). self._prefix = _prefix(kindpats) roots, dirs = _rootsanddirs(kindpats) # roots are directories which are recursively included. # If self._prefix is True, then _roots can have a fast path for # visitdir to return "all", marking things included unconditionally. # If self._prefix is False, then that optimization is unsound because # "roots" might contain entries that is not recursive (ex. roots will # include "foo/bar" for pattern "glob:foo/bar/*.c"). self._roots = set(roots) # dirs are directories which are non-recursively included. # That is, files under that directory are included. But not # subdirectories. self._dirs = set(dirs) # Try to use a more efficient visitdir implementation visitdir = _buildvisitdir(kindpats) if visitdir: self.visitdir = visitdir
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<includematcher includes=%r>" % self._pats
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") return dir in self._dirs
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<exactmatcher files=%r>" % self._files
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def matchfn(self, f): return self._m1(f) and (not self._m2(f) or self._m1.exact(f))
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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't # want to remove "dir" from the set even though it would match m2, # because the "dir" in m1 may not be a file. return self._m1.files()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 should still visit 'dir' due to the # exception we have for exact matches. return False return bool(self._m1.visitdir(dir))
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def isexact(self): return self._m1.isexact()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<differencematcher m1=%r, m2=%r>" % (self._m1, self._m2)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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: Consider encapsulating these things in a class so there's only # one thing to copy from m1. m.bad = m1.bad m.traversedir = m1.traversedir m.abs = m1.abs m.rel = m1.rel m._relativeuipath |= m1._relativeuipath return m if m2.always(): m = copy.copy(m1) m._relativeuipath |= m2._relativeuipath return m return intersectionmatcher(m1, m2)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 their files() are not always files. For # example, if intersecting a matcher "-I glob:foo.txt" with matcher of # "path:dir2", we don't want to remove "dir2" from the set. return self._m1.files() + self._m2.files()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def matchfn(self, f): return self._m1(f) and self._m2(f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def always(self): return self._m1.always() and self._m2.always()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def isexact(self): return self._m1.isexact() or self._m2.isexact()
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<intersectionmatcher m1=%r, m2=%r>" % (self._m1, self._m2)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 + "/") ] # If the parent repo had a path to this subrepo and the matcher is # a prefix matcher, this submatcher always matches. if matcher.prefix(): self._always = any(f == path for f in matcher._files)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def bad(self, f, msg): self._matcher.bad(self._path + "/" + f, msg)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def abs(self, f): return self._matcher.abs(self._path + "/" + f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def rel(self, f): return self._matcher.rel(self._path + "/" + f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def uipath(self, f): return self._matcher.uipath(self._path + "/" + f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
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 prepended. return self._matcher.matchfn(self._path + "/" + f)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def visitdir(self, dir): dir = normalizerootdir(dir, "visitdir") if dir == "": dir = self._path else: dir = self._path + "/" + dir return self._matcher.visitdir(dir)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def always(self): return self._always
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def prefix(self): return self._matcher.prefix() and not self._always
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __repr__(self): return "<subdirmatcher path=%r, matcher=%r>" % (self._path, self._matcher)
def connect(self): try: self.connection = pymongo.Connection(self.host, self.port) self.db = self.connection[self.name] except AutoReconnect: raise DatabaseException("It's not possible connect to the database")
def __init__(self, matchers): m1 = matchers[0] super(unionmatcher, self).__init__(m1._root, m1._cwd) self.traversedir = m1.traversedir self._matchers = matchers