def __init__(self, dash_s_do, version, usage, dd, lpdb, journal, provenance_log, ohash_log, refcount_log): super(MattockFS, self).__init__(version=version, usage=usage, dash_s_do=dash_s_do) self.longpathdb = lpdb self.context = carvpath.Context(lpmap=self.longpathdb) self.topdir = TopDir() self.nolistdir = NoList() # Regular expressions for select policies. self.selectre = re.compile(r'^[SVDWC]{1,5}$') self.sortre = re.compile(r'^(K|[RrOHDdWS]{1,6})$') self.archive_dd = dd self.rep = repository.Repository( reppath=self.archive_dd, context=self.context, ohash_log=ohash_log, refcount_log=refcount_log) self.ms = anycast.Actors( rep=self.rep, journal=journal, provenance=provenance_log, context=self.context, stack=self.rep.stack, col=self.rep.col) self.etcdir = EtcDir() self.topctl = TopCtl(rep=self.rep, context=self.context) self.actordir = ActorDir(actors=self.ms) self.needinit = True
def main(): repo = repository.Repository() contr = controller.Controller(repo) view = ui.UI(contr, repo) view.menu()
def list(self): _out = [] for _line in self._cmd("list").splitlines(): _line = _line.strip() if not _line: continue _out.append(repository.Repository(_line)) return _out
def main(self): """ collect github repositories using github api. """ self.exec_start_time = datetime.datetime.now() print(" * Exec start time: %s" % self._print_dt_fmt(self.exec_start_time)) repo_github_api = repository.GithubApi() json = repo_github_api.get_repositories() #print(json) repo_db = repository.DB() user_db = userInfo.DB() print(" * Searching famous repositories.") for i, item in enumerate(json["items"]): repo = repository.Repository(item) print(" L %s. Repo:%s / Lang:%s / ⭐️:%s / User:%s / UserID:%s" % (i + 1, repo.name, repo.language, repo.star, repo.owner.name, repo.owner.id)) if repo.star >= config.MANY_STAR: print(" +++ This is famous repository!!! +++") if user_db.insert(repo.owner): print(" * added new user:%s" % repo.owner.name) self.added_users.append(repo.owner) else: print(" * already exist user.") if repo_db.insert(repo): print(" * added new repository:%s" % repo.name) self.added_repositories.append(repo) print("(%s / %s) : (Searched / All)" % (len(json["items"]), json["total_count"])) print(" * Get inserted records.") searched_records = repo_db.get_records() for i, rec in enumerate(searched_records): print(" L %s. %s" % (i + 1, rec)) print(" * Get inserted users.") user_list = user_db.get_records() for i, rec in enumerate(user_list): print(" L %s. %s" % (i + 1, rec)) print(" * Added repositories: %s" % len(self.added_repositories)) print(" * Added users: %s" % len(self.added_users)) page_db = pagenation.DB() page_db.update(repo_db.table, repo_github_api.page_num + 1) print(" * Updated page number: %s" % page_db.get_page_number(repo_db.table)[0]) self.exec_end_time = datetime.datetime.now() print(" * Exec end time: %s" % self._print_dt_fmt(self.exec_end_time)) exec_time = (self.exec_end_time - self.exec_start_time) print(" * Exec time: %s" % exec_time)
def __init__(self, path): self.dir = path self.repository_file = os.path.join(self.dir, 'repository.txt') self.corpus_config_dir = os.path.join(self.dir, 'corpus-config') self.corpus_data_dir = os.path.join(self.dir, 'corpus-data') self.index_dir = os.path.join(self.dir, 'index') self.filelist_file = os.path.join(self.index_dir, 'files.txt') with open(self.repository_file) as fh: self.repository = repository.Repository(fh.read().strip())
def dump_exported_symbols(args): """Print all symbols exported using include_defs in a build file.""" logging.debug("Dumping exported symbols for " + args.build_file) bf = build_file.from_path(args.build_file) repo = repository.Repository(args.repository, args.cell_roots) symbols = bf.get_exported_symbols_transitive_closure(repo) if args.json: print(json.dumps(symbols)) else: print(os.linesep.join(symbols))
def save(a): # with open('채민알고리즘문제\도서관리패키지\\input.txt', 'w') as f: # for i in range(len(a)): # for word in a[i]: # a[i][2] = str(a[i][2]) # f.write(word) # f.write(' ') # f.write('\n') repo = repository.Repository(a) repo.update()
def request_compilation(): try: # Thanks to @AKX via #uwsgi (freenode) for helping confirm the below was # right repo = repository.Repository(flask.request) # t = threading.Thread(target=grab_git_repo, args=(repo,)) # t.start() res = celery.chain(tasks.grab_git_repo(repo), tasks.extractarchive()) res.get() except: printToLog("Failed to start the downloading thread.", 1) return ""
def com_min_algo(relation, pr, application): f = [] # set of minterm fragments pr_prime = set() # set of simple, complete and minimal fragments pr = set(pr) ## Find pi in pr which is in the application app_reqts = set(application.get_predicates()) pr = app_reqts if len(app_reqts) > len(pr) else pr assert len( app_reqts) > 0 ## Assertion Fails check your application requirements assert pr assert app_reqts.intersection(pr) ## pi should be one of the req in app_reqs + the list of predicates: pr ## TODO: SELECT Pr FROM INTERSECTION OF PREDICATE + APP_REQS intersection = list(app_reqts.intersection(pr)) pi = intersection[0] if len(intersection) else None assert pi ## Atleast one element in the intersection of APP_REQS and Pr ## remove pi from pr intersection.remove(pi) ## Add pi to pr_prime pr_prime.add(pi) ## Get the minterm fragment according to pi ## Database connection here repo = repository.Repository() f.extend(repo.fragment(relation, pi)) while True: ## find a pj elt of Pr such that p j partitions some fk of Pr0 according to Rule 1; ## if intersection is empty it is complete pj = intersection[0] if len(intersection) else None if not pj: break intersection.remove(pj) pr_prime.add(pj) ## Check minimality pr_prime = minimal(pr_prime) pr_prime = minimal_final(pr_prime) return pr_prime
def dump_export_map(args): """ Prints export map that includes all included definitions and symbols they export. """ logging.debug("Dumping export map for " + args.build_file) bf = build_file.from_path(args.build_file) repo = repository.Repository(args.repository, args.cell_roots) export_map = bf.get_export_map(repo) def to_load_import_string(import_label: label): pkg = import_label.package # include_defs package includes a file name, so we have to split it # into file name file_name = pkg.split("/")[-1] # and it's prefix - which is the new package pkg = "/".join(pkg.split("/")[:-1]) load_fn_cell = args.cell_prefix + import_label.cell if import_label.cell else "" return load_fn_cell + "//" + pkg + ":" + file_name if args.use_load_function_import_string_format: new_export_map = {} for import_string, exported_symbols in export_map.items(): new_export_map[ to_load_import_string(label.from_string(import_string)) ] = exported_symbols export_map = new_export_map if args.print_as_load_functions: def to_load_function(import_label: label, symbols: List[str]): import_string = to_load_import_string(import_label) function_args = map(lambda s: '"%s"' % s, symbols) return 'load("%s", %s)' % (import_string, ",".join(function_args)) load_functions = [] for import_string, exported_symbols in export_map.items(): load_functions.append( to_load_function(label.from_string(import_string), exported_symbols) ) if args.json: print(json.dumps(load_functions)) else: print(os.linesep.join(load_functions)) elif args.json: print(json.dumps(export_map)) else: for import_string, exported_symbols in export_map.items(): print(import_string + ":") for exported_symbol in exported_symbols: print(" " * 2 + exported_symbol)
def test_find_export_transitive_closure(self): with tempfile.TemporaryDirectory() as tmp_dir: package_dir = os.path.join(tmp_dir, 'pkg') os.mkdir(package_dir) build_file_path = os.path.join(package_dir, 'BUCK') with open(build_file_path, 'w') as buck_file: buck_file.write('include_defs("cell//pkg/DEFS")') buck_file.write(os.linesep) buck_file.write('foo = "FOO"') with open(os.path.join(package_dir, 'DEFS'), 'w') as defs_file: defs_file.write('bar = "BAR"') repo = repository.Repository('/repo', {'cell': tmp_dir}) self.assertEqual(['foo', 'bar'], build_file.from_path(build_file_path). get_exported_symbols_transitive_closure(repo))
def loadFile(): # filename = tkinter.filedialog.askopenfilename(title="Selecciona una") # newWindow() draw = repository.Repository().start() # parse('drawCookie') self.graphicsCommands = PyList() # print(draw) # print(type(draw)) parse('drawCookie') # parse('drawCookie') for cmd in self.graphicsCommands: cmd.draw(theTurtle) screen.update()
def test_find_export_transitive_closure(self): with tempfile.TemporaryDirectory() as tmp_dir: package_dir = os.path.join(tmp_dir, "pkg") os.mkdir(package_dir) build_file_path = os.path.join(package_dir, "BUCK") with open(build_file_path, "w") as buck_file: buck_file.write('include_defs("cell//pkg/DEFS")') buck_file.write(os.linesep) buck_file.write('foo = "FOO"') with open(os.path.join(package_dir, "DEFS"), "w") as defs_file: defs_file.write('bar = "BAR"') repo = repository.Repository("/repo", {"cell": tmp_dir}) self.assertEqual( ["foo", "bar"], build_file.from_path(build_file_path). get_exported_symbols_transitive_closure(repo), )
def test_get_export_map(self): with tempfile.TemporaryDirectory() as tmp_dir: package_dir = os.path.join(tmp_dir, 'pkg') os.mkdir(package_dir) build_file_path = os.path.join(package_dir, 'BUCK') with open(build_file_path, 'w') as buck_file: buck_file.write('include_defs("cell//pkg/DEFS")') buck_file.write(os.linesep) buck_file.write('foo = "FOO"') with open(os.path.join(package_dir, 'DEFS'), 'w') as defs_file: defs_file.write('include_defs("cell//pkg/DEFS2")') defs_file.write(os.linesep) defs_file.write('bar = "BAR"') with open(os.path.join(package_dir, 'DEFS2'), 'w') as defs_file: defs_file.write('baz = "BAZ"') repo = repository.Repository('/repo', {'cell': tmp_dir}) self.assertEqual({ 'cell//pkg/DEFS': ['bar'], 'cell//pkg/DEFS2': ['baz'], }, build_file.from_path(build_file_path).get_export_map(repo))
def test_get_export_map(self): with tempfile.TemporaryDirectory() as tmp_dir: package_dir = os.path.join(tmp_dir, "pkg") os.mkdir(package_dir) build_file_path = os.path.join(package_dir, "BUCK") with open(build_file_path, "w") as buck_file: buck_file.write('include_defs("cell//pkg/DEFS")') buck_file.write(os.linesep) buck_file.write('foo = "FOO"') with open(os.path.join(package_dir, "DEFS"), "w") as defs_file: defs_file.write('include_defs("cell//pkg/DEFS2")') defs_file.write(os.linesep) defs_file.write('bar = "BAR"') with open(os.path.join(package_dir, "DEFS2"), "w") as defs_file: defs_file.write('baz = "BAZ"') repo = repository.Repository("/repo", {"cell": tmp_dir}) self.assertEqual( {"cell//pkg/DEFS": ["bar"], "cell//pkg/DEFS2": ["baz"]}, build_file.from_path(build_file_path).get_export_map(repo), )
def run(self): """ Run tests for all specified builds. """ try: self.prepare_application(self.binary) ini = application.ApplicationIni(self._application) print '*** Application: %s %s' % (ini.get( 'App', 'Name'), ini.get('App', 'Version')) # Print platform details print '*** Platform: %s %s %sbit' % (str( mozinfo.os).capitalize(), mozinfo.version, mozinfo.bits) # XXX: mktemp is marked as deprecated but lets use it because with # older versions of Mercurial the target folder should not exist. print "Preparing mozmill-tests repository..." self.repository_path = tempfile.mktemp(".mozmill-tests") self._repository = repository.Repository(self.repository_url, self.repository_path) self._repository.clone() # Update the mozmill-test repository to match the Gecko branch repository_url = ini.get('App', 'SourceRepository') branch_name = self._repository.identify_branch(repository_url) self._repository.update(branch_name) if self.options.addons: self.prepare_addons() if self.options.screenshot_path: path = os.path.abspath(self.options.screenshot_path) if not os.path.isdir(path): os.makedirs(path) self.persisted["screenshotPath"] = path self.run_tests() except Exception, e: exception_type, exception, tb = sys.exc_info() traceback.print_exception(exception_type, exception, tb)
def main(): if len(sys.argv) < 2: print("Path to configuration file wasn't specified. Exiting") exit(1) config = c.Configuration(sys.argv[1]) repo = r.Repository(config.getRepo(), config) if repo.checkIfExists() == True: print("Updating repository " + repo.extractRepositoryName()) repo.Pull() else: print("Cloning repository: " + repo.extractRepositoryName()) repo.Clone() qaRepo = r.Repository(config.getQA(), config) if config.getRepo() != config.getQA(): if qaRepo.checkIfExists() == True: print("Updating repository " + qaRepo.extractRepositoryName()) qaRepo.Pull() else: print("Cloning repository: " + qaRepo.extractRepositoryName()) qaRepo.Clone() else: print("Skipping QA repository: it's the same as test repo") if not u.CheckRepoPathExists(config, repo, config.getPath()): print("Configured directory " + config.getPath() + " wasn't found in test repository. Aborting") exit(21) if not u.CheckRepoPathExists(config, qaRepo, config.getQAPath()): print("Configured directory " + config.getQAPath() + " wasn't found in test repository. Aborting") exit(22) # Workflow starts here gh = 0 try: gh = g.GitHub(config.getPrivateKey(), config.getAppID()) gh.Auth() except ValueError as err: print("GitHub auth failed: " + str(err)) exit(101) ghUser = '' ghOrg = '' ghType = '' installation_id = 0 for user in config.getUsers(): installation_id = gh.CheckUserInstallation(user) ghUser = user ghType = 'user' break for org in config.getOrgs(): installation_id = gh.CheckOrgInstallation(org) ghOrg = org ghType = 'org' break ghTitle = '' if ghType == 'user': ghTitle = ghUser else: ghTitle = ghOrg if installation_id == 0: print("Couldn't get installation for " + ghType + " " + ghTitle) exit(210) installation_id = gh.CheckRepoInstallation('crioto', 'qa-org') print("Found installation ID for " + ghTitle + ": " + str(installation_id)) gh.AuthInstallation(installation_id) print(gh.GetIssues('crioto', 'qa-org')) gh.CreateIssue('crioto', 'qa-org', 'Test Title', 'Test Text', '') print(gh.GetIssues('crioto', 'qa-org')) # gh = g.InitializeGithub(config.getToken()) # user = gh.get_user() # print(user) exit(0) builder = b.Builder( os.path.join(config.getLocalPath(), qaRepo.extractRepositoryName(), config.getQAPath())) builder.Run() issues = builder.Get() tags = [] for issue in issues: tags.append(issue.GetAbsoluteHandle()) analyzer = a.Analyzer( os.path.join(config.getLocalPath(), repo.extractRepositoryName(), config.getPath()), tags) analyzer.Run() covered = analyzer.GetMatches()
from __future__ import print_function from __future__ import unicode_literals import os import unittest import python_path import loader import repository import lookup from kube_vartypes import Confidential from user_error import UserError Resolver = lookup.Resolver repo = repository.Repository() repo.sources = 'test' class FakeClusterInfo(object): def __init__(self, name): self.name = name class TestResolver(unittest.TestCase): def get_path(self, path): return loader.Path(os.path.join(repo.basepath, 'test/test/data', path), repo) def tearDown(self): Resolver.current_cluster = None
import argparse import repository from utils import convert_to_flare parser = argparse.ArgumentParser( description="CLI Application to generate flare.json to be used in a packed circle visualization from a given repository") parser.add_argument("remote_url", help="remote url of a git repository, e.g. https://github.com/sample/sample.git") parser.add_argument("-v", "--verbose", help="shows debug messages , e.g. information on parsed files", action="store_true") args = parser.parse_args() repo = repository.Repository(remote_url=args.remote_url, verbose=args.verbose) out_file = repo.blames_to_file() convert_to_flare(out_file)
import os import shutil import repository import settingsTools import utils settings = settingsTools.settings locales = settingsTools.locales executing = utils.get_main() YES = locales.yes repo = repository.Repository(settings["github_repo"]) def download_repo(origin_branch): locales.adv_print("DOWNLOADING_NEW_VERSION") version = repo.get_version(origin_branch).version new_path = f"{repo.repository_name} {version}" if os.path.exists(new_path): if locales.adv_input("FOLDER_ALREADY_EXIST_INPUT", {"new_path": new_path}) in YES: utils.rmtree(new_path) locales.adv_print("FOLDER_DELETED") repo.clone(origin_branch) locales.adv_print("DOWNLOADING_FINISHED") return new_path def continue_actions(new_path): utils.kill_jdk()
def my_repository(articles): rep = repository.Repository("my_db_name") rep._get_connection = MagicMock() rep._get_connection().__enter__().cursor().fetchall.return_value = list( map(tuple, articles)) return rep
def test_can_get_path_to_cell(self): repo = repository.Repository("/root", {"cell": "/cell"}) self.assertEqual("/cell", repo.get_cell_path("cell"))
def __init__(self): self._repository = repository.Repository()
def test_handles_dash_in_path(self): repo = repository.Repository("/repo", {}) include = self._parse_include_def('include_defs("//third-party/DEFS")') self.assertEqual("//third-party/DEFS", include.get_location()) self.assertEqual("/repo/third-party/DEFS", include.get_include_path(repo))
def test_can_get_include_path(self): repo = repository.Repository("/repo", {"cell": "/repo/cell"}) include = self._parse_include_def('include_defs("cell//pkg/DEFS")') self.assertEqual("/repo/cell/pkg/DEFS", include.get_include_path(repo))
def __init__(self): self.repo = repository.Repository() self.map_indices = self.repo.get_map_indices()
def run_command(args): """ Run the command given by the user Keyword arguments: args -- Arguments from the command line """ # Get the password from the user passwd = getpass.getpass(prompt='Enter the repository password: '******'create': # Get a confirmation passwd_confirm = getpass.getpass(prompt='Enter the password again: ') # Check if equal if passwd != passwd_confirm: # Not equal, error print("ERR: Passwords did not match!") return repoloc = "{}/{}".format( CONFIG['Repository'].get('storage', 'repositories'), args.repository) print("Created empty repository at " + repoloc) elif args.command == 'show': if not args.name: print("ERR: Did not provide an account name to show", file=sys.stderr) if args.name in repo: print("Account: " + args.name) print("Password: "******"Password"]) if 'Comment' in repo[args.name]: print("Comments: " + repo[args.name]["Comment"]) else: print("ERR: No account with that name found in the repository", file=sys.stderr) elif args.command == 'add': if not args.name: print("ERR: Did not provide an account name", file=sys.stderr) passwd = getpass.getpass("Enter password to store: ") assert passwd != '' stored = {"Password": passwd} if args.comment: stored["Comment"] = args.comment repo[args.name] = stored elif args.command == 'remove': if not args.name: print("ERR: Did not provide an account name", file=sys.stderr) if args.name in repo: print("Account: " + args.name) conf = input("Delete account from repository? [y/N]") if conf and (conf == 'y' or conf == 'Y'): del repo[args.name] elif args.command == 'length': length = len(repo) print("{} accounts in repository.".format(length)) elif args.command == 'dump': print("Dumping private data, avert your eyes") for account in repo: print("Account: {}, Stored Data: {}".format( account, repo[account])) elif args.command == 'delete': os.remove(path=CONFIG['Repository'].get('storage', 'repositories') + '/' + str(repo) + '.repo') return # Store the repo back repo.store()
import repository customer_repository = repository.Repository() customer_repository.add({ 'name': 'Customer 1', 'address': 'Address 1' }) customer_repository.add({ 'name': 'Customer 2', 'address': 'Address 2' }) customer_repository.add({ 'name': 'Customer 3', 'address': 'Address 3' }) def index(req, res): res.render('customerlist', { 'title': 'Customers', 'items': customer_repository.get_all() }) def view(req, res): id = req.params.id customer = customer_repository.get_by_id(id) res.render('customerview', { 'title': 'Customer', 'item': customer })
from pathlib import Path import os import subprocess import utils import repository import settingsTools import jdk_tools import requests locales = settingsTools.locales settings = settingsTools.settings repo = repository.Repository(settings['github_repo']) def compile(): if settings["download_missing_files"]: version = repository.Version.get_version_file() repo.compare_tree(version.branch) if version.commit_hash is None else repo.compare_tree(version.commit_hash) locales.adv_print("BUILDING") if not os.path.exists("gradlew.bat"): with open("gradlew.bat", "w") as f: f.write(requests.get("https://raw.githubusercontent.com/michel-kraemer/gradle-download-task/master/gradlew.bat").text) process = subprocess.Popen(["gradlew.bat", "RatPoison"]) process.communicate() return_code = process.returncode utils.kill_jdk() if return_code == 0: delete_libs_folder() bat_file = utils.get_bat_name() for path in utils.search_file("java.exe"):
def test_can_get_include_path(self): repo = repository.Repository('/repo', {'cell': '/repo/cell'}) include = self._parse_include_def('include_defs("cell//pkg/DEFS")') self.assertEqual('/repo/cell/pkg/DEFS', include.get_include_path(repo))