flake8: apply E1 rules

This commit is contained in:
Yuming Zhu 2020-02-26 02:08:41 +08:00
parent 450f9249cd
commit ce1f9928af
30 changed files with 958 additions and 958 deletions

View file

@ -115,7 +115,7 @@ RPM_FILEDIGESTALGO_IDS = {
9: 'SHA384',
10: 'SHA512',
11: 'SHA224'
}
}
# rpm 4.12 introduces optional deps, but they can also be backported in some
# rpm installations. So, we need to check their real support, not only rpm
@ -678,7 +678,7 @@ class RawHeader(object):
elif pos < next:
print("** OVERLAPPING entries")
print("Tag: %d [%s], Type: %d, Offset: %x, Count: %d" \
% (tag, tags.get(tag, '?'), dtype, offset, count))
% (tag, tags.get(tag, '?'), dtype, offset, count))
if dtype == 0:
# null
print("[NULL entry]")
@ -942,10 +942,10 @@ def get_header_field(hdr, name, src_arch=False):
return []
if (src_arch and name == "ARCH"
and get_header_field(hdr, "sourcepackage")):
and get_header_field(hdr, "sourcepackage")):
# return "src" or "nosrc" arch instead of build arch for src packages
if (get_header_field(hdr, "nosource")
or get_header_field(hdr, "nopatch")):
or get_header_field(hdr, "nopatch")):
return "nosrc"
return "src"
@ -1092,7 +1092,7 @@ def check_NVRA(nvra, strict=False):
def _check_NVRA(nvra):
if isinstance(nvra, six.string_types):
nvra = parse_NVRA(nvra)
nvra = parse_NVRA(nvra)
if '-' in nvra['version']:
raise GenericError('The "-" character not allowed in version field')
if '-' in nvra['release']:
@ -1281,13 +1281,13 @@ def make_groups_spec(grplist, name='buildsys-build', buildgroup=None):
if buildgroup is None:
buildgroup = name
data = [
"""#
"""#
# This specfile represents buildgroups for mock
# Autogenerated by the build system
#
Summary: The base set of packages for a mock chroot\n""",
"""Name: %s\n""" % name,
"""Version: 1
"""Name: %s\n""" % name,
"""Version: 1
Release: 1
License: GPL
Group: Development/Build Tools
@ -1347,7 +1347,7 @@ def generate_comps(groups, expand_groups=False):
else:
return "false"
data = [
"""<?xml version="1.0"?>
"""<?xml version="1.0"?>
<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
<!-- Auto-generated by the build system -->
@ -1364,7 +1364,7 @@ def generate_comps(groups, expand_groups=False):
default = boolean_text(g['is_default'])
uservisible = boolean_text(g['uservisible'])
data.append(
""" <group>
""" <group>
<id>%(group_id)s</id>
<name>%(name)s</name>
<description>%(description)s</description>
@ -1373,13 +1373,13 @@ def generate_comps(groups, expand_groups=False):
""" % locals())
if g['biarchonly']:
data.append(
""" <biarchonly>%s</biarchonly>
""" <biarchonly>%s</biarchonly>
""" % boolean_text(True))
# print grouplist, if any
if g['grouplist'] and not expand_groups:
data.append(
""" <grouplist>
""" <grouplist>
""")
grouplist = list(g['grouplist'])
grouplist.sort(key=lambda x: x['name'])
@ -1392,14 +1392,14 @@ def generate_comps(groups, expand_groups=False):
tag = "metapkg"
if thetype:
data.append(
""" <%(tag)s type="%(thetype)s">%(name)s</%(tag)s>
""" <%(tag)s type="%(thetype)s">%(name)s</%(tag)s>
""" % locals())
else:
data.append(
""" <%(tag)s>%(name)s</%(tag)s>
""" <%(tag)s>%(name)s</%(tag)s>
""" % locals())
data.append(
""" </grouplist>
""" </grouplist>
""")
# print packagelist, if any
@ -1414,14 +1414,14 @@ def generate_comps(groups, expand_groups=False):
return "<packagereq %(opts)s>%(name)s</packagereq>" % locals()
data.append(
""" <packagelist>
""" <packagelist>
""")
if g['packagelist']:
packagelist = list(g['packagelist'])
packagelist.sort(key=lambda x: x['package'])
for p in packagelist:
data.append(
""" %s
""" %s
""" % package_entry(p))
# also include expanded list, if needed
if expand_groups and g['grouplist']:
@ -1438,11 +1438,11 @@ def generate_comps(groups, expand_groups=False):
group = group_idx.get(group_name)
if group is None:
data.append(
""" <!-- MISSING GROUP: %s -->
""" <!-- MISSING GROUP: %s -->
""" % group_name)
continue
data.append(
""" <!-- Expanding Group: %s -->
""" <!-- Expanding Group: %s -->
""" % group_name)
pkglist = list(group['packagelist'])
pkglist.sort(key=lambda x: x['package'])
@ -1451,7 +1451,7 @@ def generate_comps(groups, expand_groups=False):
if pkg_name in seen_pkg:
continue
data.append(
""" %s
""" %s
""" % package_entry(pkg))
for req in group['grouplist']:
req_name = req['name']
@ -1459,13 +1459,13 @@ def generate_comps(groups, expand_groups=False):
continue
need.append(req_name)
data.append(
""" </packagelist>
""" </packagelist>
""")
data.append(
""" </group>
""" </group>
""")
data.append(
"""</comps>
"""</comps>
""")
return ''.join(data)
@ -1836,7 +1836,7 @@ def read_config(profile_name, user_config=None):
cert_defaults = {
'cert': '~/.koji/client.crt',
'serverca': '~/.koji/serverca.crt',
}
}
for name in cert_defaults:
if result.get(name) is None:
fn = os.path.expanduser(cert_defaults[name])
@ -2100,7 +2100,7 @@ def is_requests_cert_error(e):
if ('Permission denied' in errstr or # certificate not readable
'certificate revoked' in errstr or
'certificate expired' in errstr or
'certificate verify failed' in errstr):
'certificate verify failed' in errstr):
return True
return False
@ -2473,8 +2473,8 @@ class ClientSession(object):
if principal:
if re.match(r'0[.][1-8]\b', requests_kerberos.__version__):
raise PythonImportError(
'python-requests-kerberos >= 0.9.0 required for '
'keytab auth'
'python-requests-kerberos >= 0.9.0 required for '
'keytab auth'
)
else:
kwargs['principal'] = principal
@ -2869,7 +2869,7 @@ class ClientSession(object):
raise GenericError("server returned wrong chunk size: %s != %s" % (result['size'], len(chunk)))
if result['hexdigest'] != hexdigest:
raise GenericError('upload checksum failed: %s != %s' \
% (result['hexdigest'], hexdigest))
% (result['hexdigest'], hexdigest))
ofs += len(chunk)
now = time.time()
t1 = max(now - lap, 0.00001)
@ -2889,10 +2889,10 @@ class ClientSession(object):
raise GenericError("File upload failed: %s/%s" % (path, name))
if int(result['size']) != ofs:
raise GenericError("Uploaded file is wrong length: %s/%s, %s != %s" \
% (path, name, result['size'], ofs))
% (path, name, result['size'], ofs))
if problems and result['hexdigest'] != full_chksum.hexdigest():
raise GenericError("Uploaded file has wrong checksum: %s/%s, %s != %s" \
% (path, name, result['hexdigest'], full_chksum.hexdigest()))
% (path, name, result['hexdigest'], full_chksum.hexdigest()))
self.logger.debug("Fast upload: %s complete. %i bytes in %.1f seconds", localfile, size, t2)
def _prepUpload(self, chunk, offset, path, name, verify="adler32", overwrite=False, volume=None):
@ -3125,8 +3125,8 @@ class MultiCallSession(object):
self._calls = []
if batch:
self._session.logger.debug(
"MultiCall with batch size %i, calls/groups(%i/%i)",
batch, len(calls), round(len(calls) // batch))
"MultiCall with batch size %i, calls/groups(%i/%i)",
batch, len(calls), round(len(calls) // batch))
batches = [calls[i:i+batch] for i in range(0, len(calls), batch)]
else:
batches = [calls]
@ -3390,7 +3390,7 @@ def _taskLabel(taskInfo):
else:
kickstart = os.path.basename(stuff[7])
extra = '%s, %s-%s-%s, %s, %s' % (stuff[4]['name'], stuff[0],
stuff[1], stuff[2], kickstart, stuff[3])
stuff[1], stuff[2], kickstart, stuff[3])
elif method == 'restart':
if 'request' in taskInfo:
host = taskInfo['request'][0]