From fd54f1d2c4c572c141ada5e201d42c3278ea743b Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 4 Sep 2018 13:13:18 -0400 Subject: [PATCH] Add the ability to read --project-list file from local path The import-goal --project-list option currently only supports URLs but the requests library doesn't support the file:// protocol: https://github.com/requests/requests/issues/2732 This change adds the ability to read a file path for --project-list instead of rely on URL in case you have a locally modified projects.yaml. Change-Id: I584534fb32f42e5d78941637285623ad96cf79c3 Story: 2003653 Task: 26066 --- goal_tools/import_goal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/goal_tools/import_goal.py b/goal_tools/import_goal.py index cb0b8a5..db20ed4 100644 --- a/goal_tools/import_goal.py +++ b/goal_tools/import_goal.py @@ -58,6 +58,10 @@ def _get_worklist_settings(tag): def _get_project_info(url): + # First check to see if it's a local path we can read. + if os.path.isfile(url): + with open(url) as f: + return yaml.safe_load(f) response = requests.get(url) data = yaml.safe_load(response.text) return data @@ -99,7 +103,8 @@ def main(): parser.add_argument( '--project-list', default='http://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml', # noqa - help='URL for governance projects list (%(default)s)', + help='URL or file path for governance projects.yaml list ' + '(%(default)s)', ) group = parser.add_mutually_exclusive_group() group.add_argument(