fix accessing product info from configuration
Previously, the `products` dict mapped product names in Fedora to their Bugzilla counter parts. Now that all information pertaining products is in this dictionary, the Bugzilla product name (if differing) is in the bz_product_name sub-key. Rename some variables to make their purpose a little more obvious, and not use `product` for two different things (names and the informational dictionary stored in the product cache). fixes: #32 Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
9283999992
commit
743b3aaca3
1 changed files with 13 additions and 14 deletions
|
@ -162,26 +162,27 @@ class BugzillaProxy:
|
||||||
# Old API -- in python-bugzilla. But with current server, this
|
# Old API -- in python-bugzilla. But with current server, this
|
||||||
# gives ProxyError
|
# gives ProxyError
|
||||||
for collection, product in self.config["products"].items():
|
for collection, product in self.config["products"].items():
|
||||||
self.product_cache[collection] = self.server.getcomponentsdetails(product)
|
bz_product_name = product.get('bz_product_name', collection)
|
||||||
|
self.product_cache[collection] = self.server.getcomponentsdetails(bz_product_name)
|
||||||
elif self.config['bugzilla']['compat_api'] == 'component.get':
|
elif self.config['bugzilla']['compat_api'] == 'component.get':
|
||||||
# Way that's undocumented in the partner-bugzilla api but works
|
# Way that's undocumented in the partner-bugzilla api but works
|
||||||
# currently
|
# currently
|
||||||
for collection, product in self.config["products"].items():
|
for collection, product in self.config["products"].items():
|
||||||
|
bz_product_name = product.get('bz_product_name', collection)
|
||||||
# restrict the list of info returned to only the packages of
|
# restrict the list of info returned to only the packages of
|
||||||
# interest
|
# interest
|
||||||
pkglist = [
|
pkglist = [
|
||||||
project["name"]
|
project["name"]
|
||||||
for project in pagure_projects
|
for project in pagure_projects
|
||||||
if product in project["products"]
|
if bz_product_name in project["products"]
|
||||||
]
|
]
|
||||||
products = {}
|
product_info_by_pkg = {}
|
||||||
for pkg_segment in segment(pkglist, self.config['bugzilla']['req_segment']):
|
for pkg_segment in segment(pkglist, self.config['bugzilla']['req_segment']):
|
||||||
# Format that bugzilla will understand. Strip None's that
|
# Format that bugzilla will understand. Strip None's that
|
||||||
# segment() pads out the final data segment() with
|
# segment() pads out the final data segment() with
|
||||||
query = [
|
query = [
|
||||||
dict(
|
dict(
|
||||||
product=self.config['products'][collection],
|
product=bz_product_name,
|
||||||
component=p
|
component=p
|
||||||
)
|
)
|
||||||
for p in pkg_segment
|
for p in pkg_segment
|
||||||
|
@ -191,14 +192,14 @@ class BugzillaProxy:
|
||||||
for package in raw_data['components']:
|
for package in raw_data['components']:
|
||||||
# Reformat data to be the same as what's returned from
|
# Reformat data to be the same as what's returned from
|
||||||
# getcomponentsdetails
|
# getcomponentsdetails
|
||||||
product = dict(
|
product_info = dict(
|
||||||
initialowner=package['default_assignee'],
|
initialowner=package['default_assignee'],
|
||||||
description=package['description'],
|
description=package['description'],
|
||||||
initialqacontact=package['default_qa_contact'],
|
initialqacontact=package['default_qa_contact'],
|
||||||
initialcclist=package['default_cc']
|
initialcclist=package['default_cc']
|
||||||
)
|
)
|
||||||
products[package['name'].lower()] = product
|
product_info_by_pkg[package['name'].lower()] = product_info
|
||||||
self.product_cache[collection] = products
|
self.product_cache[collection] = product_info_by_pkg
|
||||||
|
|
||||||
def invert_user_cache(self):
|
def invert_user_cache(self):
|
||||||
""" Takes the user_cache built when querying FAS and invert it so
|
""" Takes the user_cache built when querying FAS and invert it so
|
||||||
|
@ -314,6 +315,8 @@ class BugzillaProxy:
|
||||||
e.args = ('ProtocolError', e.errcode, e.errmsg)
|
e.args = ('ProtocolError', e.errcode, e.errmsg)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
bz_product_name = self.config['products'][collection].get('bz_product_name', collection)
|
||||||
|
|
||||||
# Set the qacontact_email and name
|
# Set the qacontact_email and name
|
||||||
default_qa_contact_email = self.config['default_qa_contact_email']
|
default_qa_contact_email = self.config['default_qa_contact_email']
|
||||||
default_qa_contact = f"<default: {default_qa_contact_email.split('@', 1)[0]}@...>"
|
default_qa_contact = f"<default: {default_qa_contact_email.split('@', 1)[0]}@...>"
|
||||||
|
@ -350,7 +353,7 @@ class BugzillaProxy:
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
# Changes occurred. Submit a request to change via xmlrpc
|
# Changes occurred. Submit a request to change via xmlrpc
|
||||||
data['product'] = self.config['products'][collection]
|
data['product'] = bz_product_name
|
||||||
data['component'] = package
|
data['component'] = package
|
||||||
|
|
||||||
if self.config["verbose"]:
|
if self.config["verbose"]:
|
||||||
|
@ -414,16 +417,12 @@ class BugzillaProxy:
|
||||||
new_poc=owner_email,
|
new_poc=owner_email,
|
||||||
prev_poc=product[pkg_key]['initialowner'],
|
prev_poc=product[pkg_key]['initialowner'],
|
||||||
name=package,
|
name=package,
|
||||||
product=self.config['products'][collection],
|
product=bz_product_name,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if self.config.get("print-no-change"):
|
if self.config.get("print-no-change"):
|
||||||
bz_product_name = self.config['products'][collection].get(
|
|
||||||
'bz_product_name', collection
|
|
||||||
)
|
|
||||||
print(f"[NOCHANGE] {package}/{bz_product_name}")
|
print(f"[NOCHANGE] {package}/{bz_product_name}")
|
||||||
else:
|
else:
|
||||||
bz_product_name = self.config['products'][collection].get('bz_product_name', collection)
|
|
||||||
if retired:
|
if retired:
|
||||||
if self.config['verbose']:
|
if self.config['verbose']:
|
||||||
print(f"[NOADD] {bz_product_name}/{package} (is retired)")
|
print(f"[NOADD] {bz_product_name}/{package} (is retired)")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue