From 4c697a63ced6680681d3d2f27b8be84bcacb9998 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 21 Nov 2019 11:18:08 +0100 Subject: [PATCH] Allow specifying which projects to update This allows to specify which projects to update instead of running on all of them. The project should be provided in form of namespace/name, for example: ``-p rpms/koji rpms/guake``. Signed-off-by: Pierre-Yves Chibon --- distgit_bugzilla_sync/script.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index b5906bd..a4949e6 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -484,10 +484,14 @@ class DistgitBugzillaSync: parser.add_argument('--add-email-overrides-file', metavar='EMAIL_OVERRIDES_FILE', dest='addl_email_overrides_files', action='append', help="File(s) from which to read additional email overrides") + parser.add_argument( + '-p', '--project', dest='projects', nargs='+', + help='Update one or more projects (provided as namespace/name), ' + 'in all of its products') self.args = parser.parse_args() - def get_pagure_project(self): + def get_pagure_project(self, project_list=None): """ Builds a large list of all the projects on pagure. Each item in that list is a dict containing: - the namespace of the project @@ -511,14 +515,17 @@ class DistgitBugzillaSync: # Combine and collapse those two into a single list: self.pagure_projects = [] + if project_list: + project_list = set(tuple(p.split("/", 1)) for p in project_list) for namespace, entries in pagure_namespace_to_poc.items(): for name, poc in entries.items(): - self.pagure_projects.append(dict( - namespace=namespace, - name=name, - poc=poc, - watchers=pagure_namespace_to_cc[namespace][name], - )) + if not project_list or (namespace, name) in project_list: + self.pagure_projects.append(dict( + namespace=namespace, + name=name, + poc=poc, + watchers=pagure_namespace_to_cc[namespace][name], + )) def add_branches_product_and_summary(self): """ For each project retrieved this method adds branches, products @@ -645,12 +652,14 @@ class DistgitBugzillaSync: print("Building a cache of the rpm packages' summary") self.rpm_summary = package_summary.get_package_summary() - self.get_pagure_project() + self.get_pagure_project(self.args.projects) self.add_branches_product_and_summary() if self.env["verbose"]: print(f"{len(self.pagure_projects)} projects to consider") + if not self.pagure_projects: + return if self.env["verbose"]: times["data structure end"] = time.time() delta = times["data structure end"] - times["start"]