add list-deliverables command

Add a command to print a list of the names of deliverables that match
specified criteria, like having a certain release.

Change-Id: I52844446e288513b0a575c922a83d72f803f9f17
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-11-21 12:20:16 -05:00
parent 93311929e6
commit 415e86c465
4 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import os
import os.path
# Try to guess where the deliverables directory is relative to where
# the code is imported from.
_venv = os.environ.get('VIRTUAL_ENV', '')
if _venv:
deliverable_dir = os.path.dirname(_venv)
if deliverable_dir.endswith('.tox'):
deliverable_dir = os.path.dirname(deliverable_dir)
deliverable_dir = os.path.join(deliverable_dir, 'deliverables')
else:
deliverable_dir = os.path.join(
os.path.dirname(__file__),
'../deliverables',
)

View File

@ -0,0 +1,79 @@
# 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.
from __future__ import print_function
import argparse
import openstack_releases
from openstack_releases import defaults
from openstack_releases import deliverable
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--team',
help='the name of the project team, such as "Nova" or "Oslo"',
)
parser.add_argument(
'--deliverable',
help='the name of the deliverable, such as "nova" or "oslo.config"',
)
parser.add_argument(
'--series',
default=defaults.RELEASE,
help='the release series, such as "newton" or "ocata"',
)
model = parser.add_mutually_exclusive_group()
model.add_argument(
'--model',
help='the release model, such as "cycle-with-milestones" or "independent"',
)
model.add_argument(
'--cycle-based',
action='store_true',
default=False,
help='include all cycle-based code repositories',
)
parser.add_argument(
'--type',
help='deliverable type, such as "library" or "service"',
)
parser.add_argument(
'--deliverables-dir',
default=openstack_releases.deliverable_dir,
help='location of deliverable files',
)
args = parser.parse_args()
# Deal with the inconsistency of the name for the independent
# directory.
series = args.series
if series == 'independent':
series = '_independent'
all_deliv = deliverable.Deliverables(
root_dir=args.deliverables_dir,
collapse_history=False,
)
for entry in all_deliv.get_deliverables(args.team, series):
deliv = deliverable.Deliverable(*entry)
if args.model and deliv.model != args.model:
continue
if args.cycle_based and not deliv.is_cycle_based:
continue
if args.type and deliv.type != args.type:
continue
print(deliv.name)

View File

@ -177,3 +177,26 @@ class Deliverables(object):
self._deliverable_from_filename(filename),
self._by_filename.get(filename, {}),
)
class Deliverable(object):
def __init__(self, team, series, name, data):
self.team = team
self.series = series
self.name = name
self._data = data
@property
def model(self):
if self.series == '_independent':
return 'independent'
return self._data.get('release-model', '').lstrip('_')
@property
def is_cycle_based(self):
return self.model.startswith('cycle-')
@property
def type(self):
return self._data.get('type', 'other')

View File

@ -29,6 +29,7 @@ console_scripts =
interactive-release = openstack_releases.cmds.interactive_release:main
missing-releases = openstack_releases.cmds.missing:main
check-diff-start = openstack_releases.cmds.check_diff_start:main
list-deliverables = openstack_releases.cmds.list_deliverables:main
[extras]
sphinxext =