Update email_stats.py for the big tent

Changes to the projects.yaml (nee programs.yaml) in the
openstack/governance repo to accommodate big tent terminology have
resulted in a need to similarly adjust the script interpreting it.
While at it, update the variable names within the script for
clarity.

Change-Id: Ie001901c33749aa41181a09e43576bf9d516b4e5
This commit is contained in:
Jeremy Stanley 2015-02-11 00:05:12 +00:00
parent bab20a4e62
commit 85f6bb9db8

View File

@ -35,8 +35,8 @@ import yaml
MAILTO_RE = re.compile('mailto:(.*)') MAILTO_RE = re.compile('mailto:(.*)')
USERNAME_RE = re.compile('username:(.*)') USERNAME_RE = re.compile('username:(.*)')
EXTRA_ATC_RE = re.compile('^[^#][^:]*: ([^\(]*) \(([^@]*@[^\)]*)\) \[[^\[]*\]') EXTRA_ATC_RE = re.compile('^[^#][^:]*: ([^\(]*) \(([^@]*@[^\)]*)\) \[[^\[]*\]')
PROGRAMS_URL = ('https://git.openstack.org/cgit/openstack/governance/plain' PROJECTS_URL = ('https://git.openstack.org/cgit/openstack/governance/plain'
'/reference/programs.yaml') '/reference/projects.yaml')
EXTRA_ATCS_URL = ('https://git.openstack.org/cgit/openstack/governance/plain' EXTRA_ATCS_URL = ('https://git.openstack.org/cgit/openstack/governance/plain'
'/reference/extra-atcs') '/reference/extra-atcs')
@ -57,7 +57,7 @@ def get_account(accounts, num):
return a return a
def project_stats(project, output, begin, end, keyfile, user): def repo_stats(repo, output, begin, end, keyfile, user):
accounts = {} accounts = {}
for row in open('accounts.tab'): for row in open('accounts.tab'):
@ -96,7 +96,7 @@ def project_stats(project, output, begin, end, keyfile, user):
atcs = [] atcs = []
QUERY = "project:%s status:merged" % project QUERY = "project:%s status:merged" % repo
client = paramiko.SSHClient() client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@ -152,7 +152,7 @@ def project_stats(project, output, begin, end, keyfile, user):
'gerrit query %s resume_sortkey:%s --all-approvals' 'gerrit query %s resume_sortkey:%s --all-approvals'
' --format JSON' % (QUERY, last_sortkey)) ' --format JSON' % (QUERY, last_sortkey))
print 'project: %s' % project print 'repo: %s' % repo
print 'examined %s changes' % count print 'examined %s changes' % count
print 'earliest timestamp: %s' % earliest print 'earliest timestamp: %s' % earliest
writer = csv.writer(open(output, 'w')) writer = csv.writer(open(output, 'w'))
@ -161,13 +161,13 @@ def project_stats(project, output, begin, end, keyfile, user):
print print
def get_projects(url): def get_repos(url):
programs_yaml = yaml.load(requests.get(url).text) projects_yaml = yaml.load(requests.get(url).text)
projects = [] repos = []
for program in programs_yaml: for project in projects_yaml:
for project in programs_yaml[program]['projects']: for repo in projects_yaml[project]['projects']:
projects.append(project['repo']) repos.append(repo['repo'])
return projects return repos
def get_extra_atcs(url): def get_extra_atcs(url):
@ -199,16 +199,16 @@ def main():
options, args = optparser.parse_args() options, args = optparser.parse_args()
if options.ref: if options.ref:
programs_url = '%s?id=%s' % (PROGRAMS_URL, options.ref) projects_url = '%s?id=%s' % (PROJECTS_URL, options.ref)
extra_atcs_url = '%s?id=%s' % (EXTRA_ATCS_URL, options.ref) extra_atcs_url = '%s?id=%s' % (EXTRA_ATCS_URL, options.ref)
else: else:
programs_url = PROGRAMS_URL projects_url = PROJECTS_URL
extra_atcs_url = EXTRA_ATCS_URL extra_atcs_url = EXTRA_ATCS_URL
for project in get_projects(programs_url): for repo in get_repos(projects_url):
output = 'out/%s.csv' % project.split('/')[-1] output = 'out/%s.csv' % repo.split('/')[-1]
project_stats(project, output, options.begin, options.end, repo_stats(repo, output, options.begin, options.end,
options.keyfile, options.user) options.keyfile, options.user)
writer = csv.writer(open('out/extra-atcs.csv', 'w')) writer = csv.writer(open('out/extra-atcs.csv', 'w'))
for atc in get_extra_atcs(extra_atcs_url): for atc in get_extra_atcs(extra_atcs_url):