summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-04-23 18:32:33 +0200
committerOlav Vitters <olav@vitters.nl>2020-04-23 18:32:33 +0200
commit92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a (patch)
treeeadce4908116bfefcacf6c96c06f9f78665045e9
parent10c4c981e3e8f731486fbef2b437fbac0b9c0631 (diff)
downloadmgagnome-92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a.tar
mgagnome-92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a.tar.gz
mgagnome-92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a.tar.bz2
mgagnome-92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a.tar.xz
mgagnome-92ea9edff8aa9fc34ba7ba6d5ff1e73cfd7aaf0a.zip
pylint fixes
-rwxr-xr-xmgagnome134
1 files changed, 83 insertions, 51 deletions
diff --git a/mgagnome b/mgagnome
index 6cf4824..3687211 100755
--- a/mgagnome
+++ b/mgagnome
@@ -49,6 +49,9 @@ import concurrent.futures
# for merging comments in order
import collections
+# for debugging output
+import pprint
+
# check-latest
import requests
@@ -424,8 +427,10 @@ class SpecFile():
if change_to is None:
change_to = ""
- if 'keeppre' in regexp.groupindex: change_to += r'\g<keeppre>'
- if 'keeppost' in regexp.groupindex: change_to += r'\g<keeppost>'
+ if 'keeppre' in regexp.groupindex:
+ change_to += r'\g<keeppre>'
+ if 'keeppost' in regexp.groupindex:
+ change_to += r'\g<keeppost>'
data, nr = regexp.subn(change_to, data)
if nr:
made_changes = True
@@ -523,9 +528,9 @@ class SpecFile():
# XXX -- apparently this is really inefficient with e.g. apache
mo2 = re_prep_patches.search(data)
- patch_nrs_header = set([give_patchnr(mo) for mo in re_patch_header.finditer(data)])
- patch_nrs_any = set([give_patchnr(mo) for mo in re_patch_any.finditer(data)])
- patch_nrs_valid = set([give_patchnr(mo) for mo in re_patch_valid.finditer(mo2.group(0))]) if mo2 else set()
+ patch_nrs_header = set((give_patchnr(mo) for mo in re_patch_header.finditer(data)))
+ patch_nrs_any = set((give_patchnr(mo) for mo in re_patch_any.finditer(data)))
+ patch_nrs_valid = set((give_patchnr(mo) for mo in re_patch_valid.finditer(mo2.group(0)))) if mo2 else set()
if not patch_nrs_header:
# XXX -- werird, self.patches should've returned 0 already
@@ -592,12 +597,16 @@ class SpecFile():
br = {}
for req, flag, ver in itertools.zip_longest(requires, require_flags, require_ver):
# bitmask other than 15 means the require is (probably?) a require for a trigger or script
- if flag & 15 != flag: continue
+ if flag & 15 != flag:
+ continue
ver_cmp = ""
- if flag & rpm.RPMSENSE_LESS: ver_cmp += '<'
- if flag & rpm.RPMSENSE_GREATER: ver_cmp += '>'
- if flag & rpm.RPMSENSE_EQUAL: ver_cmp += '='
+ if flag & rpm.RPMSENSE_LESS:
+ ver_cmp += '<'
+ if flag & rpm.RPMSENSE_GREATER:
+ ver_cmp += '>'
+ if flag & rpm.RPMSENSE_EQUAL:
+ ver_cmp += '='
br[req] = (ver_cmp, ver)
return br
@@ -615,7 +624,9 @@ class SpecFile():
"""Remove a patch from the spec file"""
# Uses string as well as numeric comparisons to determine which patch to remove
nrs = [str(patchnr), patchnr]
- if patchnr == 0: nrs.append('')
+ if patchnr == 0:
+ nrs.append('')
+
with open(self.path, "r", encoding="utf-8") as f:
data = f.read()
@@ -845,7 +856,8 @@ class SpecFile():
if judgement < max_judgement:
print("WARNING: %s!" % (msg))
- if not force: return False
+ if not force:
+ return False
data = self._check_can_update(force)
if data is None:
@@ -877,7 +889,9 @@ class SpecFile():
tries = 0
while tries < SLEEP_TIMES:
tries += 1
- if tries > 1: time.sleep(SLEEP_REPEAT * 2 ** (tries // 5))
+ if tries > 1:
+ time.sleep(SLEEP_REPEAT * 2 ** (tries // 5))
+
try:
# Download new tarball
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd)
@@ -949,7 +963,7 @@ class Upstream():
parser.close()
files = parser.urls
- tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)])
+ tarballs = set((filename.replace('/', '') for filename in files if good_dir.search(filename)))
if self.limit is not None:
tarballs.intersection_update(self.limit)
@@ -1038,13 +1052,14 @@ class Downstream():
$ urpmq --whatprovides $search_for --provides"""
if not cls._provide_to_alternate:
- provide_has_multiple_pkgs = set()
_provide_to_pkg = {}
_pkg_to_provide = {}
for myline in subprocess.check_output(['urpmf', "--qf", "%name\t%provides\t%arch", '.']).decode("utf-8").splitlines():
pkgname, pkgprovide, pkgarch = myline.split("\t")
- if pkgarch in ('src', 'i586'): continue
- if '-debug' in pkgprovide: continue
+ if pkgarch in ('src', 'i586'):
+ continue
+ if '-debug' in pkgprovide:
+ continue
if "[" in pkgprovide and pkgprovide.endswith("]"):
pkgprovidepart = pkgprovide.rstrip("]").partition("[")
@@ -1069,7 +1084,8 @@ class Downstream():
for key in provide_has_single:
# XXX - optimize memory usage somewhat
- if '(' in key and not ')(' in key: continue
+ if '(' in key and not ')(' in key:
+ continue
for pkgname in _provide_to_pkg[key]:
for pkgprovide in _pkg_to_provide[pkgname]:
@@ -1240,11 +1256,13 @@ def cmd_group_owner(options):
groups = set(options.group)
output = [pkg.split("\t") for pkg in subprocess.check_output(["urpmf", "-F|", "--qf", "%group\t%name\t%sourcerpm\t%version\t%release", "."]).decode("utf-8").splitlines()]
- if not output: return
+ if not output:
+ return
# Filter by groups
output = [pkg for pkg in output if pkg[0] in groups]
- if not output: return
+ if not output:
+ return
packages = {}
for group, name, sourcerpm, version, release in output:
@@ -1253,16 +1271,19 @@ def cmd_group_owner(options):
source = sourcerpm if sourcerpm else name
end = ".src.rpm"
- if source.endswith(end): source = source[:len(source) - len(end)]
+ if source.endswith(end):
+ source = source[:len(source) - len(end)]
end = "-%s-%s" %(version, release)
- if source.endswith(end): source = source[:len(source) - len(end)]
+ if source.endswith(end):
+ source = source[:len(source) - len(end)]
- if source not in packages[group]: packages[group][source] = set()
+ if source not in packages[group]:
+ packages[group][source] = set()
packages[group][source].add(name)
- maints = dict([line.rpartition(" ")[::2] for line in subprocess.check_output(["mgarepo", "maintdb", "get"]).decode("utf-8").splitlines()])
+ maints = {line.rpartition(" ")[::2] for line in subprocess.check_output(["mgarepo", "maintdb", "get"]).decode("utf-8").splitlines()}
def get_output(source, maints, packages):
for source in list(packages.keys()):
@@ -1297,7 +1318,7 @@ def cmd_cleanup(options):
for path in dirs:
try:
- binaries = set([l.split(' ', 1)[1] for l in open(os.path.join(root, path, 'SOURCES', 'sha1.lst')).read().splitlines()])
+ binaries = set((l.split(' ', 1)[1] for l in open(os.path.join(root, path, 'SOURCES', 'sha1.lst')).read().splitlines()))
except IndexError:
print(os.path.join(root, path, 'SOURCES', 'sha1.lst'))
# shutil.rmtree(os.path.join(root, path))
@@ -1328,9 +1349,12 @@ def cmd_ls(options):
for package, module, package_version, spec_version, downstream_files in streams:
sys.stdout.write(package)
- if options.spec: sys.stdout.write('/SPECS/%s.spec' % package)
- if options.upstream: sys.stdout.write("\t%s" % module)
- if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version))
+ if options.spec:
+ sys.stdout.write('/SPECS/%s.spec' % package)
+ if options.upstream:
+ sys.stdout.write("\t%s" % module)
+ if options.show_version:
+ sys.stdout.write("\t%s\t%s" % (spec_version, package_version))
print()
def cmd_check_version(options):
@@ -1428,8 +1452,6 @@ def cmd_clean_spec_multi(args):
made_changes = False
- changes = {}
-
# Convert perl- and -devel buildrequires into perl() and pkgconfig() requires
if options.convert_br:
re_prov_get_version = re.compile(r'^[^(]+\([^)]+-(?P<version>[0-9]+\.[0-9][0-9.]*)\)$')
@@ -1443,9 +1465,9 @@ def cmd_clean_spec_multi(args):
'check_provide': lambda prov: prov.startswith('pkgconfig('),
'basereqs': lambda req: [req[:-len('-devel')]],
'basereq_no_version': lambda basereqs: [basereq.rstrip('1234567890.') for basereq in basereqs if basereq[-1] in '1234567890'],
- 'versions_from_basereq': lambda basereqs: set([basereq[len(basereq.rstrip('01234567890.')):] for basereq in basereqs if basereq[-1] in '1234567890']),
- 'versions_basereq_extra': lambda versions: set(["%s.0" % version for version in versions if '.' not in version]),
- 'extra': lambda basereq, versions: \
+ 'versions_from_basereq': lambda basereqs: set((basereq[len(basereq.rstrip('01234567890.')):] for basereq in basereqs if basereq[-1] in '1234567890')),
+ 'versions_basereq_extra': lambda versions: set(("%s.0" % version for version in versions if '.' not in version)),
+ 'extra': lambda basereqs, versions: \
['pkgconfig(%s)' % basereq for basereq in basereqs] +
['pkgconfig(%s)' % basereq[len('lib'):] if basereq.startswith('lib') else 'pkgconfig(lib%s)' % basereq for basereq in basereqs] +
['pkgconfig(%s-%s)' % (basereq, version) for basereq in basereqs for version in versions],
@@ -1482,8 +1504,9 @@ def cmd_clean_spec_multi(args):
},
}
- for convert_br, keys in convert_brs.items():
- if 'disabled' in keys and keys['disabled']: continue
+ for keys in convert_brs.values():
+ if 'disabled' in keys and keys['disabled']:
+ continue
keys['changes'] = {}
br_old = [r for r in list(br.keys()) if keys['check_br'](r)]
@@ -1550,7 +1573,8 @@ def cmd_clean_spec_multi(args):
if provides_alt:
- if change_to is None: no_change[req] = (provides_alt, check_for)
+ if change_to is None:
+ no_change[req] = (provides_alt, check_for)
else:
no_alt.add(req)
@@ -1560,9 +1584,14 @@ def cmd_clean_spec_multi(args):
if not options.doit:
if options.debug:
for keys in list(convert_brs.items()):
- if 'changes' in keys and keys['changes']: pprint.pprint(keys['changes'])
- if no_alt: print("WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt)))
- if no_change and options.debug: pprint.pprint(no_change)
+ if 'changes' in keys and keys['changes']:
+ pprint.pprint(keys['changes'])
+
+ if no_alt:
+ print("WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt)))
+
+ if no_change and options.debug:
+ pprint.pprint(no_change)
else:
convert_brs = {}
@@ -1604,7 +1633,7 @@ def cmd_check_spec_multi(args):
s = Downstream.package_spec(package)
try:
- patches = s.patches
+ s.patches
except SpecFileError:
print('ERROR: Broken spec file for package %s' % package, file=sys.stderr)
return False
@@ -1653,7 +1682,7 @@ def cmd_new_release(options):
# Determine the package name
if options.upstream:
try:
- package = Downstream().get_downstream_from_upstream(pkgs, options.version)[0]
+ package = Downstream().get_downstream_from_upstream(pkg, options.version)[0]
except ValueError as e:
print("ERROR: %s" % e, file=sys.stderr)
success = False
@@ -1708,7 +1737,8 @@ def cmd_new_release(options):
# retry submission various times, could be that some dependencies are being built at the same time
@retry(subprocess.CalledProcessError, tries=10, delay=300, backoff=1.5)
- def _submit(): subprocess.check_call(cmd, cwd=cwd)
+ def _submit():
+ subprocess.check_call(cmd, cwd=cwd)
_submit()
except subprocess.CalledProcessError:
success = False
@@ -1848,7 +1878,9 @@ def cmd_parse_ftp_release_list(options):
hexdigest = msg['X-Module-SHA256-tar.xz']
except KeyError as e:
print("ERROR: %s" % e, file=stderr)
- if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
+ if options.mail:
+ _send_reply_mail(stdout, msg, options.mail, error=True)
+
sys.exit(1)
try:
@@ -1856,13 +1888,16 @@ def cmd_parse_ftp_release_list(options):
except (ValueError, SpecFileError) as e:
#print(bytes("ERROR: %s" % str(e), 'UTF-8'), file=stderr)
stderr.write(bytes("ERROR: %s" % str(e), 'UTF-8'))
- if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
+ if options.mail:
+ _send_reply_mail(stdout, msg, options.mail, error=True)
+
sys.exit(1)
if options.wait or options.fork:
# maildrop aborts and will try to deliver after 5min
# fork to avoid this
- if os.fork() != 0: sys.exit(0)
+ if os.fork() != 0:
+ sys.exit(0)
if options.wait:
# wait SLEEP_INITIAL after the message was sent
@@ -1872,7 +1907,8 @@ def cmd_parse_ftp_release_list(options):
msg_time = email.utils.mktime_tz(t)
secs = SLEEP_INITIAL - (time.time() - msg_time)
- if secs > 0: time.sleep(secs)
+ if secs > 0:
+ time.sleep(secs)
error = False
for package in packages:
@@ -1885,7 +1921,8 @@ def cmd_parse_ftp_release_list(options):
if subprocess.call(cmd, stdout=stdout, stderr=stderr):
error = True
- if options.mail: _send_reply_mail(stdout, msg, options.mail, packages=packages, error=error)
+ if options.mail:
+ _send_reply_mail(stdout, msg, options.mail, packages=packages, error=error)
def main():
description = """Mageia GNOME commands."""
@@ -2049,11 +2086,6 @@ def main():
if not hasattr(options, 'submit'):
options.submit = not options.distro
- if options.debug:
- # Often used in debugging
- global pprint
- import pprint
-
Downstream.PKGROOT = options.PKGROOT
if options.distro:
Downstream.PKGROOT = os.path.join(options.PKGROOT, options.distro)