From a0dd6dabfd3edb861dcaf99c70d32053f4b23448 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 8 Mar 2017 10:56:24 -0500 Subject: [PATCH] Using a configuration file to list repos --- .gitignore | 1 + analyze.py | 30 +++++++++++++++++++----------- fetch.py | 21 ++++++++++++++++----- repos.json | 8 ++++++++ 4 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 repos.json diff --git a/.gitignore b/.gitignore index f04f5e9..6284c91 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ data/*.json +www diff --git a/analyze.py b/analyze.py index 45f6349..2857e02 100755 --- a/analyze.py +++ b/analyze.py @@ -3,14 +3,24 @@ import json import datetime -repos = ["yunohost", "yunohost-admin", "SSOwat", "moulinette", "doc", "ynh-dev", - "apps", "CI_package_check", "example_ynh", "package_linter", "Simone", - "project-organization", "build.yunohost.org", "dynette", "YunoPorts", - "rebuildd", "cd_build", "install_script"] - - prs = {} +def get_repos(): + + repos_by_name = {} + + with open("repos.json", "r") as f: + repos_by_team = json.loads(f.read()) + + for team, team_repos in repos_by_team.items(): + for repo in team_repos: + if repo not in repos_by_name.keys(): + repos_by_name[repo] = [team] + else: + repos_by_name[repo].append(team) + + return repos_by_name + def githubDateToDaysAgo(date): now = datetime.datetime.now() @@ -44,7 +54,7 @@ def priority(pr): def main(): - for repo in repos: + for repo, teams in get_repos().items(): print("Analyzing %s ..." % repo) @@ -64,12 +74,10 @@ def main(): "id": "%s-%s" % (repo, issue["number"]), "createdDaysAgo": githubDateToDaysAgo(issue["created_at"]), "updatedDaysAgo": githubDateToDaysAgo(issue["updated_at"]), - "url": issue["pull_request"]["html_url"] + "url": issue["pull_request"]["html_url"], + "teams": teams } - #if len(pr["title"]) > 53: - # pr["title"] = pr["title"][0:50] + "..." - if isPRDying(pr): pr["labels"].append("dying") pr["priority"] = priority(pr) diff --git a/fetch.py b/fetch.py index 4f70484..4323627 100755 --- a/fetch.py +++ b/fetch.py @@ -1,14 +1,25 @@ #!/usr/bin/python3 import requests +import json -repos = ["yunohost", "yunohost-admin", "SSOwat", "moulinette", "doc", "ynh-dev", - "apps", "CI_package_check", "example_ynh", "package_linter", "Simone", - "project-organization", "build.yunohost.org", "dynette", "YunoPorts", - "rebuildd", "cd_build", "install_script"] +def get_repos(): + repos_by_name = {} -for repo in repos: + with open("repos.json", "r") as f: + repos_by_team = json.loads(f.read()) + + for team, team_repos in repos_by_team.items(): + for repo in team_repos: + if repo not in repos_by_name.keys(): + repos_by_name[repo] = [team] + else: + repos_by_name[repo].append(team) + + return repos_by_name + +for repo in get_repos().keys(): print("Fetching pull requests for %s" % repo) diff --git a/repos.json b/repos.json new file mode 100644 index 0000000..5572dcb --- /dev/null +++ b/repos.json @@ -0,0 +1,8 @@ +{ +"core": ["yunohost", "yunohost-admin", "SSOwat", "moulinette", "Vagrantfile", + "ynh-dev" ], +"doc": [ "doc", "Simone", "project-organization" ], +"apps": [ "apps", "CI_package_check", "example_ynh", "package_linter" ], +"infra": [ "build.yunohost.org", "dynette", "YunoPorts", "rebuildd", "cd_build", + "install_script", "trotinette","bicyclette", "Vagrantfile"] +}