def load_project(project_id): """loads a project by the provided ID""" with app.app_context(): location = app.config.get("LIBINTEL_DATA_DIR") path_to_file = location + '/out/' + project_id + '.json' with open(path_to_file) as json_file: project = json.load(json_file) json_file.close() return Project(**project)
def get_all_project_names(sig_list): logger.info("Start to get all project names.") for sig in sig_list: url = URL_SIG + sig.get_name() + PATH_PROJECT print("Start to get projects for sig " + sig.get_name()) names = get_all_pattern_strings_from_a_url(url, PATTERN_PROJECT) for name in names: project = Project(name) sig.add_project(project) print("End to get projects for sig " + sig.get_name()) logger.info("End to get all project names.")
def main(): # load arguments arguments = argumentsParser() # filter logs if (not arguments.debug): logger.remove() # filter arguments filterArgument(arguments) # starter program initMenu() # init object project project = Project().initProject(arguments) # carrega o menu da solution solutionMenu(project) # fltra as respostas do menu filterAnswerMenu(project)
def load_all_projects(): """loads all available projects""" with app.app_context(): location = app.config.get("LIBINTEL_DATA_DIR") projects = ProjectList(None) list_filenames = os.listdir(location + '/out/') for filename in list_filenames: if filename.endswith('.json'): path_to_file = location + '/out/' + filename try: with open(path_to_file) as json_file: project = json.load(json_file) json_file.close() projects.add_project(Project(**project)) except FileNotFoundError: continue except TypeError: continue return projects
def create_new_project(): """ creates the project folder if it not exists :return: the newly created or updated project. returns 500 if errors occurs on writing the project to disc. """ project_json = request.get_json(silent=True) project = Project(**project_json) if re.match('\d+', project.project_id) or re.match( '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\Z', project.project_id): print('valid ID') try: project_service.create_project(project) app.logger.info('project {}: created'.format(project.project_id)) return json.dumps(project, default=lambda o: o.__getstate__()) except IOError: app.logger.error('project {}: could not create project'.format( project.project_id)) return Response("could not create project", status=500) else: app.logger.error('project {}: invalid ID'.format(project.project_id)) return Response("could not create project", status=500)
logger.info("Start to get all issues of a project.") issues = [] patten_issue = FORMAT_ISSUE.format(project.get_name()) issue_strings = get_all_pattern_strings_from_a_url( SRC_OPENEULER + project.get_name() + "/issues", patten_issue) for e in issue_strings: issue = Issue('', GITEE + e, IssueStatus.OPEN) issues.append(issue) logger.info("End to get all issues of a project.") return issues @staticmethod def get_all_prs(project): logger.info("Start to get all pull requests of a project.") prs = [] patten_pr = FORMAT_PULLREQUEST.format(project.get_name()) pr_strings = get_all_pattern_strings_from_a_url( SRC_OPENEULER + project.get_name() + "/pulls", patten_pr) for e in pr_strings: pr = PullRequest('', GITEE + e, PullRequestStatus.OPEN) prs.append(pr) logger.info("End to get all pull requests of a project.") return prs if __name__ == '__main__': from model.Project import Project project = Project("tensorflow") prs = ProjectHelp.get_all_prs(project) print(prs)