consistently use dictionary literals

Aside from not using two different idioms for the same thing, it
performs better (not noticeably in our case, but hey).

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2019-11-25 13:58:02 +01:00
parent 743b3aaca3
commit 247ede734b

View file

@ -181,23 +181,20 @@ class BugzillaProxy:
# 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( {'product': bz_product_name, 'component': p}
product=bz_product_name,
component=p
)
for p in pkg_segment for p in pkg_segment
if p is not None if p is not None
] ]
raw_data = self.server._proxy.Component.get(dict(names=query)) raw_data = self.server._proxy.Component.get({'names': query})
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_info = dict( product_info = {
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'],
) }
product_info_by_pkg[package['name'].lower()] = product_info product_info_by_pkg[package['name'].lower()] = product_info
self.product_cache[collection] = product_info_by_pkg self.product_cache[collection] = product_info_by_pkg
@ -472,10 +469,10 @@ def _get_pdc_branches(session, repo):
:return: a list of the repo's branches :return: a list of the repo's branches
""" """
branches_url = '{0}component-branches/'.format(env['pdc_url']) branches_url = '{0}component-branches/'.format(env['pdc_url'])
params = dict( params = {
global_component=repo['name'], 'global_component': repo['name'],
type=env['pdc_types'][repo['namespace']] 'type': env['pdc_types'][repo['namespace']],
) }
if config["verbose"]: if config["verbose"]:
print('Querying {0} {1}'.format(branches_url, params)) print('Querying {0} {1}'.format(branches_url, params))
rv = session.get(branches_url, params=params, timeout=60) rv = session.get(branches_url, params=params, timeout=60)
@ -659,12 +656,12 @@ class DistgitBugzillaSync:
for namespace, entries in pagure_namespace_to_poc.items(): for namespace, entries in pagure_namespace_to_poc.items():
for name, poc in entries.items(): for name, poc in entries.items():
if not project_list or (namespace, name) in project_list: if not project_list or (namespace, name) in project_list:
self.pagure_projects.append(dict( self.pagure_projects.append({
namespace=namespace, 'namespace': namespace,
name=name, 'name': name,
poc=poc, 'poc': poc,
watchers=pagure_namespace_to_cc[namespace][name], 'watchers': pagure_namespace_to_cc[namespace][name],
)) })
@property @property
def namespace_to_product(self): def namespace_to_product(self):