From 7b98e09cee48188486e987a1c26dad8e4f687c55 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 30 Apr 2015 21:06:24 +0000 Subject: [PATCH] Add list_repos_by_project.py Add a script to list the repositories owned by a given project team. Change-Id: Ief2e40de6901942192bcdc170807b65317eca291 --- README.rst | 8 +++++ list_repos_by_project.py | 67 ++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 76 insertions(+) create mode 100755 list_repos_by_project.py diff --git a/README.rst b/README.rst index 29f79af..638bec0 100644 --- a/README.rst +++ b/README.rst @@ -184,6 +184,14 @@ stable branches using a pre-tagged release version. This script makes that easy to coordinate and ensures that the desired version also exists in launchpad as a released milestone. +list_repos_by_project.py +------------------------ + +Read the project list from the governance repository and print a list +of the repositories owned by the named project. + +./list_repos_by_project.py Oslo + Base tools ========== diff --git a/list_repos_by_project.py b/list_repos_by_project.py new file mode 100755 index 0000000..3dd31ab --- /dev/null +++ b/list_repos_by_project.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Print a list of the repositories managed by a given project. +""" + +from __future__ import print_function + +import argparse +import requests +import yaml + +PROJECTS_LIST = "http://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml" # noqa + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--project-list', + default=PROJECTS_LIST, + help='a URL pointing to a projects.yaml file, defaults to %(default)s', + ) + parser.add_argument( + '--code-only', + default=False, + action='store_true', + help='only show repositories containing code, not docs or templates', + ) + parser.add_argument( + 'project', + help='the name of the project, such as "Nova" or "Oslo"', + ) + args = parser.parse_args() + + r = requests.get(args.project_list) + project_data = yaml.load(r.text) + + if args.project not in project_data: + parser.error('No project %r found in the project list' % args.project) + repo_names = sorted( + p['repo'] + for p in project_data[args.project]['projects'] + ) + if args.code_only: + repo_names = [ + name + for name in repo_names + if not name.endswith('-specs') and 'cookiecutter' not in name + ] + + for name in repo_names: + print(name) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index 67abc3f..386cb68 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ requests>=1.1 Jinja2>=2.6 # BSD License (3 clause) oslo.concurrency>=1.4.1 # Apache-2.0 parawrap +PyYAML>=3.1.0