Add --project-file option
This patch adds a new -p (--project-file) option which can be used to specify an external grouping of projects used to generate the report. The format of the project file can be YAML or JSON (YAML example is included in the README.md). The format is a list of dict's to leave open the option for future expansion (fields other than 'name' might also be useful.) Change-Id: I5e74fa118296c4531c988f4804749d6a6c1b957a
This commit is contained in:
parent
e2b4f2d0b3
commit
3971f290fe
11
README.md
11
README.md
|
@ -35,7 +35,16 @@ An output directory called 'out\_report' is generated in the current directory.
|
|||
|
||||
Alternately you can execute reviewday in a tox environment by using:
|
||||
|
||||
tox -erun
|
||||
tox -erun
|
||||
|
||||
## Customizing the projects
|
||||
|
||||
If you wish to customize the output of reviewday you can use the -p (--project-file) option to provide a custom project names file. This file should be
|
||||
a valid YAML/JSON file formatted like this:
|
||||
|
||||
projects:
|
||||
- name: dib-utils
|
||||
- name: diskimage-builder
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -8,12 +8,17 @@ from reviewday.util import create_report
|
|||
from reviewday.launchpad import LaunchPad
|
||||
from reviewday.mergeprop import MergeProp
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
import yaml
|
||||
|
||||
optparser = OptionParser()
|
||||
|
||||
optparser.add_option('-o', '--out-dir', dest='out_dir',
|
||||
help='set output directory [default = %default]',
|
||||
default='out_report', type='string')
|
||||
optparser.add_option('-p', '--project-file', dest='project_file',
|
||||
help='A YAML or JSON file specifying the project list',
|
||||
type='string')
|
||||
|
||||
(options, args) = optparser.parse_args()
|
||||
|
||||
|
@ -68,7 +73,15 @@ PROJECTS = [
|
|||
'zaqar',
|
||||
]
|
||||
|
||||
for project in PROJECTS:
|
||||
proj_names = PROJECTS
|
||||
if options.project_file:
|
||||
if os.path.exists(options.project_file):
|
||||
with open(options.project_file) as cf:
|
||||
proj_names = []
|
||||
for proj in yaml.load(cf.read()).get("projects"):
|
||||
proj_names.append(proj['name'])
|
||||
|
||||
for project in proj_names:
|
||||
if project not in projects:
|
||||
projects[project] = []
|
||||
for review in gerrit_reviews(project):
|
||||
|
|
Loading…
Reference in New Issue