pep8: consistently use lower case variable names
Previously, we had a mixture of lower_case_name and mixedCaseName. Use lower case names except where external APIs force us to do otherwise. Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
26c3288951
commit
be18b8f87a
1 changed files with 43 additions and 43 deletions
|
@ -112,16 +112,16 @@ def segment(iterable, chunk, fill=None):
|
|||
|
||||
class BugzillaProxy:
|
||||
|
||||
def __init__(self, bzServer, username, password, config):
|
||||
self.bzXmlRpcServer = bzServer
|
||||
def __init__(self, bz_server, username, password, config):
|
||||
self.bz_xmlrpc_server = bz_server
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
self.server = Bugzilla(
|
||||
url=self.bzXmlRpcServer,
|
||||
url=self.bz_xmlrpc_server,
|
||||
user=self.username,
|
||||
password=self.password)
|
||||
self.productCache = {}
|
||||
self.product_cache = {}
|
||||
|
||||
# Connect to the fedora account system
|
||||
self.fas = AccountSystem(
|
||||
|
@ -132,13 +132,13 @@ class BugzillaProxy:
|
|||
self.config = config
|
||||
|
||||
try:
|
||||
self.userCache = self.fas.people_by_key(
|
||||
self.user_cache = self.fas.people_by_key(
|
||||
key='username',
|
||||
fields=['bugzilla_email'])
|
||||
except fedora.client.ServerError:
|
||||
# Sometimes, building the userCache up front fails with a timeout.
|
||||
# Sometimes, building the user cache up front fails with a timeout.
|
||||
# It's ok, we build the cache as-needed later in the script.
|
||||
self.userCache = {}
|
||||
self.user_cache = {}
|
||||
|
||||
def build_product_cache(self, pagure_project):
|
||||
""" Cache the bugzilla info about each package in each product.
|
||||
|
@ -149,7 +149,7 @@ class BugzillaProxy:
|
|||
# Old API -- in python-bugzilla. But with current server, this
|
||||
# gives ProxyError
|
||||
for collection, product in self.config["products"].items():
|
||||
self.productCache[collection] = self.server.getcomponentsdetails(product)
|
||||
self.product_cache[collection] = self.server.getcomponentsdetails(product)
|
||||
elif self.config['bugzilla']['compat_api'] == 'component.get':
|
||||
# Way that's undocumented in the partner-bugzilla api but works
|
||||
# currently
|
||||
|
@ -185,7 +185,7 @@ class BugzillaProxy:
|
|||
initialcclist=package['default_cc']
|
||||
)
|
||||
products[package['name'].lower()] = product
|
||||
self.productCache[collection] = products
|
||||
self.product_cache[collection] = products
|
||||
|
||||
def _get_bugzilla_email(self, username):
|
||||
'''Return the bugzilla email address for a user.
|
||||
|
@ -194,14 +194,14 @@ class BugzillaProxy:
|
|||
reloads the cache from fas and tries again.
|
||||
'''
|
||||
try:
|
||||
return self.userCache[username]['bugzilla_email'].lower()
|
||||
return self.user_cache[username]['bugzilla_email'].lower()
|
||||
except KeyError:
|
||||
if username.startswith('@'):
|
||||
group = self.fas.group_by_name(username[1:])
|
||||
bz_email = group.mailing_list
|
||||
if bz_email is None:
|
||||
return
|
||||
self.userCache[username] = {
|
||||
self.user_cache[username] = {
|
||||
'bugzilla_email': bz_email}
|
||||
else:
|
||||
person = self.fas.person_by_username(username)
|
||||
|
@ -209,21 +209,21 @@ class BugzillaProxy:
|
|||
if bz_email is None:
|
||||
|
||||
return
|
||||
self.userCache[username] = {'bugzilla_email': bz_email}
|
||||
return self.userCache[username]['bugzilla_email'].lower()
|
||||
self.user_cache[username] = {'bugzilla_email': bz_email}
|
||||
return self.user_cache[username]['bugzilla_email'].lower()
|
||||
|
||||
def add_edit_component(self, package, collection, owner, description=None,
|
||||
qacontact=None, cclist=None, print_fas_names=False):
|
||||
'''Add or update a component to have the values specified.
|
||||
'''
|
||||
# Turn the cclist into something usable by bugzilla
|
||||
initialCCEmails = []
|
||||
initialCCFASNames = []
|
||||
initial_cc_emails = []
|
||||
initial_cc_fasnames = []
|
||||
for watcher in cclist:
|
||||
bz_email = self._get_bugzilla_email(watcher)
|
||||
if bz_email:
|
||||
initialCCEmails.append(bz_email)
|
||||
initialCCFASNames.append(watcher)
|
||||
initial_cc_emails.append(bz_email)
|
||||
initial_cc_fasnames.append(watcher)
|
||||
else:
|
||||
print(f"** {watcher} has no bugzilla_email or mailing_list set "
|
||||
f"({collection}/{package}) **")
|
||||
|
@ -231,13 +231,13 @@ class BugzillaProxy:
|
|||
# Add owner to the cclist so comaintainers taking over a bug don't
|
||||
# have to do this manually
|
||||
owner_email = self._get_bugzilla_email(owner)
|
||||
if owner_email not in initialCCEmails:
|
||||
initialCCEmails.append(owner_email)
|
||||
initialCCFASNames.append(owner)
|
||||
if owner_email not in initial_cc_emails:
|
||||
initial_cc_emails.append(owner_email)
|
||||
initial_cc_fasnames.append(owner)
|
||||
|
||||
# Lookup product
|
||||
try:
|
||||
product = self.productCache[collection]
|
||||
product = self.product_cache[collection]
|
||||
except xmlrpc.client.Fault as e:
|
||||
# Output something useful in args
|
||||
e.args = (e.faultCode, e.faultString)
|
||||
|
@ -246,8 +246,8 @@ class BugzillaProxy:
|
|||
e.args = ('ProtocolError', e.errcode, e.errmsg)
|
||||
raise
|
||||
|
||||
pkgKey = package.lower()
|
||||
if pkgKey in product:
|
||||
pkg_key = package.lower()
|
||||
if pkg_key in product:
|
||||
# edit the package information
|
||||
data = {}
|
||||
|
||||
|
@ -258,21 +258,21 @@ class BugzillaProxy:
|
|||
qacontact_email = 'extras-qa@fedoraproject.org'
|
||||
|
||||
# Check for changes to the owner, qacontact, or description
|
||||
if product[pkgKey]['initialowner'] != owner_email:
|
||||
if product[pkg_key]['initialowner'] != owner_email:
|
||||
data['initialowner'] = owner_email
|
||||
|
||||
if description and product[pkgKey]['description'] != description:
|
||||
if description and product[pkg_key]['description'] != description:
|
||||
data['description'] = description
|
||||
|
||||
if qacontact and product[pkg_key]['initialqacontact'] != qacontact_email:
|
||||
data['initialqacontact'] = qacontact_email
|
||||
|
||||
if len(product[pkgKey]['initialcclist']) != len(initialCCEmails):
|
||||
data['initialcclist'] = initialCCEmails
|
||||
if len(product[pkg_key]['initialcclist']) != len(initial_cc_emails):
|
||||
data['initialcclist'] = initial_cc_emails
|
||||
else:
|
||||
for cc_member in product[pkgKey]['initialcclist']:
|
||||
if cc_member not in initialCCEmails:
|
||||
data['initialcclist'] = initialCCEmails
|
||||
for cc_member in product[pkg_key]['initialcclist']:
|
||||
if cc_member not in initial_cc_emails:
|
||||
data['initialcclist'] = initial_cc_emails
|
||||
break
|
||||
|
||||
if data:
|
||||
|
@ -288,10 +288,10 @@ class BugzillaProxy:
|
|||
if key == 'initialowner':
|
||||
value = owner
|
||||
else:
|
||||
value = initialCCFASNames
|
||||
print(f" {key} changed to `{value}`")
|
||||
value = initial_cc_fasnames
|
||||
print(f" {key} changed to FAS name(s) `{value}`")
|
||||
else:
|
||||
print(f" {key} changed from `{product[pkgKey][key]} "
|
||||
print(f" {key} changed from `{product[pkg_key][key]} "
|
||||
f"to `{data.get(key)}`")
|
||||
|
||||
# FIXME: initialowner has been made mandatory for some
|
||||
|
@ -321,8 +321,8 @@ class BugzillaProxy:
|
|||
'initialowner': owner_email,
|
||||
'initialqacontact': qacontact_email
|
||||
}
|
||||
if initialCCEmails:
|
||||
data['initialcclist'] = initialCCEmails
|
||||
if initial_cc_emails:
|
||||
data['initialcclist'] = initial_cc_emails
|
||||
|
||||
if self.config["verbose"]:
|
||||
print('[ADDCOMP] %s/%s' % (data["product"], data["component"]))
|
||||
|
@ -338,7 +338,7 @@ class BugzillaProxy:
|
|||
raise
|
||||
|
||||
|
||||
def send_email(fromAddress, toAddress, subject, message, ccAddress=None):
|
||||
def send_email(from_address, to_address, subject, message, cc_address=None):
|
||||
'''Send an email if there's an error.
|
||||
|
||||
This will be replaced by sending messages to a log later.
|
||||
|
@ -348,15 +348,15 @@ def send_email(fromAddress, toAddress, subject, message, ccAddress=None):
|
|||
pass
|
||||
else:
|
||||
msg = EmailMessage()
|
||||
msg.add_header('To', ','.join(toAddress))
|
||||
msg.add_header('From', fromAddress)
|
||||
msg.add_header('To', ','.join(to_address))
|
||||
msg.add_header('From', from_address)
|
||||
msg.add_header('Subject', subject)
|
||||
if ccAddress is not None:
|
||||
msg.add_header('Cc', ','.join(ccAddress))
|
||||
toAddress = toAddress + ccAddress
|
||||
if cc_address is not None:
|
||||
msg.add_header('Cc', ','.join(cc_address))
|
||||
to_address += cc_address
|
||||
msg.set_payload(message)
|
||||
smtp = smtplib.SMTP('bastion')
|
||||
smtp.sendmail(fromAddress, toAddress, msg.as_string())
|
||||
smtp.sendmail(from_address, to_address, msg.as_string())
|
||||
smtp.quit()
|
||||
|
||||
|
||||
|
@ -459,7 +459,7 @@ class DistgitBugzillaSync:
|
|||
[user_email],
|
||||
subject='Please fix your bugzilla.redhat.com account',
|
||||
message=self.env['tmpl_user_email'],
|
||||
ccAddress=self.env['notify_emails'],
|
||||
cc_address=self.env['notify_emails'],
|
||||
)
|
||||
|
||||
new_data[user_email] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue