def _ignore(self): files = [self._join('.hgignore')] for name, path in self._ui.configitems("ui"): if name == 'ignore' or name.startswith('ignore.'): # we need to use os.path.join here rather than self._join # because path is arbitrary and user-specified files.append(os.path.join(self._rootdir, util.expandpath(path))) return ignore.ignore(self._root, files, self._ui.warn)
def add_reviews(self, reviews): """ add a list of reviews to the db. Args: reviews (list(tuple)): list of tuples of reviews - str and is the review positive - boolean """ with self._lock: with sqlite3.connect(self._file_path) as connection: cursor = connection.cursor() with ignore(sqlite3.OperationalError): cursor.execute("CREATE TABLE %s (%s TEXT, %s INTEGER)" % (TABLE_NAME, TEXT_PARAMETER, GRADE_PARAMETER)) connection.commit() cursor.executemany("INSERT INTO %s VALUES(?, ?)" % TABLE_NAME, reviews) connection.commit()
def _ignore(self): files = [self._join('.hgignore')] for name, path in self._ui.configitems("ui"): if name == 'ignore' or name.startswith('ignore.'): files.append(util.expandpath(path)) return ignore.ignore(self._root, files, self._ui.warn)
self._pl = st[:20], st[20:40] except IOError, err: if err.errno != errno.ENOENT: raise return self._pl elif name == '_dirs': self._dirs = {} for f in self._map: if self[f] != 'r': self._incpath(f) return self._dirs elif name == '_ignore': files = [self._join('.hgignore')] for name, path in self._ui.configitems("ui"): if name == 'ignore' or name.startswith('ignore.'): files.append(os.path.expanduser(path)) self._ignore = ignore.ignore(self._root, files, self._ui.warn) return self._ignore elif name == '_slash': self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/' return self._slash elif name == '_checkexec': self._checkexec = util.checkexec(self._root) return self._checkexec else: raise AttributeError, name def _join(self, f): return os.path.join(self._root, f) def getcwd(self): cwd = os.getcwd()
def _ignore(self): files = [self._join(".hgignore")] for name, path in self._ui.configitems("ui"): if name == "ignore" or name.startswith("ignore."): files.append(os.path.expanduser(path)) return ignore.ignore(self._root, files, self._ui.warn)
parser.add_argument('destination') args = parser.parse_args() regex = '.*@.*:\d+\/.*' origin_src = 'remote' if re.match(regex, args.source) else 'local' origin_dst = 'remote' if re.match(regex, args.destination) else 'local' if __name__ == '__main__': print 'golem at work' sftp_src = remote.sftpclient(args.source) if origin_src == 'remote' else None sftp_dst = remote.sftpclient(args.destination) if origin_dst == 'remote' else None root_src = remote.info(args.source).root if origin_src == 'remote' else os.path.abspath(args.source) root_dst = remote.info(args.destination).root if origin_dst == 'remote' else os.path.abspath(args.destination) ignore = ignore(root_src + os.sep + 'config.json', sftp_src) if args.backup: print 'backuping folder ' + root_dst zip(root_dst, paths(root_dst, ignore, sftp_dst), args.backup, sftp_dst) for file_src in paths(root_src, ignore, sftp_src): file_dst = file_src.replace(root_src, root_dst) if utils.isdir(file_src, sftp_src): print 'creating folder ' + file_dst utils.mkdir(file_dst, sftp_dst) else: data_src = copy(file_src, sftp_src) if exists(file_dst): data_dst = copy(file_dst, sftp_dst) md5_data_src = md5(data_src).digest()