From c0112f7166b2439a0a61fdc4be46ae974498ec6e Mon Sep 17 00:00:00 2001 From: melanie witt Date: Thu, 16 Aug 2018 17:40:08 +0000 Subject: [PATCH] Dynamically find releases for move-implemented-specs This adds a shallow directory walk to find the available releases for moving implemented specs, so we don't have to update the script per release to add a release choice. Change-Id: I80ea14f07da9361b26645d997de0fcbe4ba19afc --- tools/move_implemented_specs.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/move_implemented_specs.py b/tools/move_implemented_specs.py index 2f14ad082..4f8d25499 100644 --- a/tools/move_implemented_specs.py +++ b/tools/move_implemented_specs.py @@ -23,6 +23,16 @@ from launchpadlib import launchpad LPCACHEDIR = os.path.expanduser('~/.launchpadlib/cache') +def get_choices(): + # 3-tuple (dirpath, dirnames, filenames) + for _, choices, _ in os.walk('specs'): + choices.remove('backlog') + choices.sort() + # Quit walking (release dirs are at the first level in 'specs') + break + return choices + + def get_options(): parser = argparse.ArgumentParser( description='Move implemented specs for a given release. Requires ' @@ -33,14 +43,7 @@ def get_options(): help='Do everything except move the files.', action='store_true') parser.add_argument('release', help='The release to process.', - choices=['juno', - 'kilo', - 'liberty', - 'mitaka', - 'newton', - 'ocata', - 'pike', - 'queens']) + choices=get_choices()) return parser.parse_args()