summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-04-24 16:15:27 +0200
committerOlav Vitters <olav@vitters.nl>2020-04-24 16:15:27 +0200
commita90817e93ca532dad8a0246060850332ae3d6dda (patch)
tree94f2e80260b417a5aeca6c5e806af53baa1be7c7
parent508d7c0da72e2bd3f7d18a81a2940a83e06dfdbc (diff)
downloadmgagnome-a90817e93ca532dad8a0246060850332ae3d6dda.tar
mgagnome-a90817e93ca532dad8a0246060850332ae3d6dda.tar.gz
mgagnome-a90817e93ca532dad8a0246060850332ae3d6dda.tar.bz2
mgagnome-a90817e93ca532dad8a0246060850332ae3d6dda.tar.xz
mgagnome-a90817e93ca532dad8a0246060850332ae3d6dda.zip
pylint fixes and order subcommands alphabetically
-rwxr-xr-xmgagnome182
1 files changed, 91 insertions, 91 deletions
diff --git a/mgagnome b/mgagnome
index d0285d5..8abe1f2 100755
--- a/mgagnome
+++ b/mgagnome
@@ -110,7 +110,7 @@ def retry(exceptions, tries=4, delay=3, backoff=2, logger=None):
return deco_retry
-def version_cmp(a, b):
+def version_cmp(version_a, version_b):
"""Compares two versions
Returns
@@ -119,7 +119,7 @@ def version_cmp(a, b):
1 if a > b
"""
- return rpm.labelCompare(('1', a, '1'), ('1', b, '1'))
+ return rpm.labelCompare(('1', version_a, '1'), ('1', version_b, '1'))
def get_latest_version(versions, max_version=None):
"""Gets the latest version number
@@ -161,11 +161,11 @@ def get_majmin(version, module=None):
def get_safe_max_version(version, module=None):
- m = re_majmin.match(version)
- if version is None or not m:
+ match = re_majmin.match(version)
+ if version is None or not match:
return None
- majmin = get_majmin(m.group(1), module)
+ majmin = get_majmin(match.group(1), module)
min_nr = int(majmin[1])
@@ -272,8 +272,8 @@ def call_editor(filename):
for editor in editors:
try:
ret = subprocess.call([editor, filename])
- except OSError as e:
- if e.errno == 2:
+ except OSError as exc:
+ if exc.errno == 2:
continue
raise
@@ -363,8 +363,8 @@ class SpecFile():
os.chdir(self.cwd)
rpm.delMacro("_topdir")
rpm.addMacro("_topdir", os.path.join(self.cwd, '..'))
- ts = rpm.ts()
- spec = ts.parseSpec(self.path)
+ trans_set = rpm.ts()
+ spec = trans_set.parseSpec(self.path)
try:
srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \
else spec.sources()
@@ -372,7 +372,7 @@ class SpecFile():
# Reraise this into a more specific exception
raise SpecFileError from exc
finally:
- # ts.parseSpec can affect changing of internal macros, e.g. redefining things like mkrel and so on
+ # trans_set.parseSpec can affect changing of internal macros, e.g. redefining things like mkrel and so on
# reload the config to fix this
rpm.reloadConfig()
return dict((os.path.basename(name), [name, 0 if no == 2147483647 and flags == 2 else no]) for name, no, flags in srclist if flag is None or flags == flag)
@@ -535,7 +535,7 @@ class SpecFile():
print("NOTICE: Unable to automatically convert %s patches into %%autopatch (header/patch/valid: %s, %s, %s)" % (self.module, len(patch_nrs_header), len(patch_nrs_any), len(patch_nrs_valid)), file=sys.stderr)
return made_changes, data
- patch_flags = set([0 if match.group('strip') is None else match.group('strip') for match in re_patch_valid.finditer(match2.group(0))])
+ patch_flags = set((0 if match.group('strip') is None else match.group('strip') for match in re_patch_valid.finditer(match2.group(0))))
if len(patch_flags) != 1:
print("NOTICE: Unable to automatically convert patches into as different -p / strip levels used", file=sys.stderr)
@@ -543,9 +543,9 @@ class SpecFile():
# Whoot, we can convert!!
change_to = "%%autopatch -p%s\n" % list(patch_flags)[0]
- prep, n1 = re_patch_valid.subn(change_to.replace('\\', '\\\\'), match2.group(0), count=1)
- prep, n2 = re_patch_valid.subn('', prep)
- if len(patch_nrs_valid) != n1 + n2:
+ prep, subs1 = re_patch_valid.subn(change_to.replace('\\', '\\\\'), match2.group(0), count=1)
+ prep, subs2 = re_patch_valid.subn('', prep)
+ if len(patch_nrs_valid) != subs1 + subs2:
print("WARNING: Couldn't replace patches?!? Likely error in program logic", file=sys.stderr)
return made_changes, data
@@ -893,9 +893,9 @@ class SpecFile():
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd)
# success, so exit loop
break
- except subprocess.CalledProcessError as e:
+ except subprocess.CalledProcessError as exc:
# mgarepo sync returns 1 if the tarball cannot be downloaded
- if e.returncode != 1:
+ if exc.returncode != 1:
self._revert_changes()
print("ERROR: Could not download tarball", file=sys.stderr)
return False
@@ -970,10 +970,10 @@ class Upstream():
versions = None
url = '%s%s/cache.json' % (cls.URL, module)
- r = requests.get(url)
- j = r.json()
- if j is not None and len(j) > 2 and module in j[2]:
- versions = j[2][module]
+ request = requests.get(url)
+ json = request.json()
+ if json is not None and len(json) > 2 and module in json[2]:
+ versions = json[2][module]
return versions
@@ -1003,9 +1003,9 @@ class Downstream():
PACKAGES.add(srpm)
if '.tar' in filename:
- r = self.re_file.match(filename)
- if r:
- fileinfo = r.groupdict()
+ match = self.re_file.match(filename)
+ if match:
+ fileinfo = match.groupdict()
module = fileinfo['module']
if module not in TARBALLS:
@@ -1302,10 +1302,10 @@ def cmd_group_owner(options):
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()):
+ for package in list(packages.keys()):
maint = maints.get(source, "?")
- yield "\t".join((maint, source, ",".join(sorted(packages[source]))))
+ yield "\t".join((maint, source, ",".join(sorted(packages[package]))))
first = True
for group in list(packages.keys()):
@@ -1437,8 +1437,8 @@ def cmd_patches(options):
print("\t".join((module, package, str(p))))
def cmd_check_prep(options):
- s = Downstream.package_spec(options.package)
- s.check_and_update_patches()
+ spec = Downstream.package_spec(options.package)
+ spec.check_and_update_patches()
def cmd_clean_spec_multi(args):
options, package = args
@@ -1457,10 +1457,10 @@ def cmd_clean_spec_multi(args):
print('ERROR: Cannot find spec file for package %s' % package, file=sys.stderr)
return False
- s = Downstream.package_spec(package)
+ spec = Downstream.package_spec(package)
try:
- if not s.ensure_no_local_changes(options.force):
+ if not spec.ensure_no_local_changes(options.force):
return False
except subprocess.CalledProcessError:
# Package was probably not checked out or something
@@ -1472,7 +1472,7 @@ def cmd_clean_spec_multi(args):
# 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.]*)\)$')
- br = s.buildrequires
+ br = spec.buildrequires
no_alt = set()
no_change = {}
convert_brs = {
@@ -1626,25 +1626,25 @@ def cmd_clean_spec_multi(args):
# keys_with_changes.append({'changes': [], 'desc': 'unsplit BRs'})
for keys in keys_with_changes:
- if s.update_br(keys['changes'], change_description=keys['desc']):
+ if spec.update_br(keys['changes'], change_description=keys['desc']):
made_changes = True
- if s.clean_spec():
+ if spec.clean_spec():
made_changes = True
# If we made it this far, checkin the changes
if made_changes:
if options.doit:
- Downstream.ci(package, s.changes, cwd=cwd)
- if s.should_rebuild:
+ Downstream.ci(package, spec.changes, cwd=cwd)
+ if spec.should_rebuild:
cmd = ['mgagnome', 'rebuild', '-s', '-m', 'to test removal of deprecated macros', package]
subprocess.call(cmd, cwd=cwd)
else:
# show the diff and undo all changes
- if s.should_rebuild:
+ if spec.should_rebuild:
print("NOTICE: Package should be rebuilt")
- print(s.changes)
- s.ensure_no_local_changes(force=True)
+ print(spec.changes)
+ spec.ensure_no_local_changes(force=True)
return made_changes
@@ -1657,9 +1657,9 @@ def cmd_check_spec_multi(args):
return False
- s = Downstream.package_spec(package)
+ spec = Downstream.package_spec(package)
try:
- s.patches
+ spec.patches
except SpecFileError:
print('ERROR: Broken spec file for package %s' % package, file=sys.stderr)
return False
@@ -1699,7 +1699,7 @@ def cmd_clean_spec(options):
# Hack: warm alternative provides cache
if options.convert_br:
Downstream.alternative_provides('XXXX')
- with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
+ with concurrent.futures.ProcessPoolExecutor(max_workers=workers) as executor:
executor.map(cmd_clean_spec_multi, ((options, package) for package in packages))
def cmd_new_release(options):
@@ -1728,30 +1728,30 @@ def cmd_new_release(options):
# SpecFile class handles the actual version+release change
# XXX - module should reflect upstream name, this gives it the package name
- s = Downstream.package_spec(package)
- cur_release = s.release
+ spec = Downstream.package_spec(package)
+ cur_release = spec.release
try:
new_release = int(cur_release)+1
except ValueError:
print("ERROR: Cannot increase the release for package %s" % pkg, file=sys.stderr)
success = False
continue
- cur_version = s.version
+ cur_version = spec.version
print("%s-%s => %s-%s" % (cur_version, cur_release, cur_version, new_release))
# XXX - Duplicate check as should not revert changes if specfile has already been changed
- if not s.ensure_no_local_changes(options.force):
+ if not spec.ensure_no_local_changes(options.force):
success = False
continue
- if not s.update_release(new_release, options.reason, force=options.force):
+ if not spec.update_release(new_release, options.reason, force=options.force):
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd, stdout=subprocess.DEVNULL)
success = False
continue
try:
# If we made it this far, checkin the changes
- Downstream.ci(package, s.changes, cwd=cwd)
+ Downstream.ci(package, spec.changes, cwd=cwd)
# Submit is optional
if options.submit:
@@ -1768,8 +1768,8 @@ def cmd_package_new_version(options):
if options.upstream:
try:
package = Downstream().get_downstream_from_upstream(options.package, options.version)[0]
- except ValueError as e:
- print("ERROR: %s" % e, file=sys.stderr)
+ except ValueError as exc:
+ print("ERROR: %s" % exc, file=sys.stderr)
sys.exit(1)
else:
package = options.package
@@ -1786,14 +1786,14 @@ def cmd_package_new_version(options):
# SpecFile class handles the actual version+release change
# XXX - module should reflect upstream name, this gives it the package name
- s = Downstream.package_spec(package)
- print("%s => %s" % (s.version, options.version))
+ spec = Downstream.package_spec(package)
+ print("%s => %s" % (spec.version, options.version))
# XXX - Duplicate check as should not revert changes if specfile has already been changed
- if not s.ensure_no_local_changes(options.force):
+ if not spec.ensure_no_local_changes(options.force):
sys.exit(1)
- if not s.update_version(options.version, force=options.force):
+ if not spec.update_version(options.version, force=options.force):
# XXX - hack to automatically revert changes when auto upgrading from ftp release list
if options.hexdigest is not None:
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd, stdout=subprocess.DEVNULL)
@@ -1801,7 +1801,7 @@ def cmd_package_new_version(options):
# Check hash, if given
if options.hexdigest is not None:
- sources = [name for name, value in s.sources.items() if '://' in value[0]]
+ sources = [name for name, value in spec.sources.items() if '://' in value[0]]
if not sources:
print("ERROR: Cannot determine source file (for hash check)!", file=sys.stderr)
sys.exit(1)
@@ -1823,7 +1823,7 @@ def cmd_package_new_version(options):
try:
# If we made it this far, checkin the changes
- Downstream.ci(package, s.changes, cwd=cwd)
+ Downstream.ci(package, spec.changes, cwd=cwd)
# Submit is optional
if options.submit:
@@ -1833,7 +1833,7 @@ def cmd_package_new_version(options):
sys.exit(1)
def cmd_parse_ftp_release_list(options):
- def _send_reply_mail(contents, orig_msg, to, packages=None, error=False):
+ def _send_reply_mail(contents, orig_msg, to_addr, packages=None, error=False):
"""Send an reply email"""
contents.seek(0)
msg = MIMEText(contents.read(), _charset='utf-8')
@@ -1856,13 +1856,13 @@ def cmd_parse_ftp_release_list(options):
subject = "Re: %s%s" % (orig_msg['Subject'], subjecterror)
msg['Subject'] = subject
- msg['To'] = to
+ msg['To'] = to_addr
msg["In-Reply-To"] = orig_msg["Message-ID"]
msg["References"] = orig_msg["Message-ID"]
# Call sendmail program directly so it doesn't matter if the service is running
cmd = ['/usr/sbin/sendmail', '-oi', '--']
- cmd.extend([to])
+ cmd.extend([to_addr])
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
p.stdin.write(msg.as_bytes())
p.stdin.flush()
@@ -1892,9 +1892,9 @@ def cmd_parse_ftp_release_list(options):
try:
packages = Downstream().get_downstream_from_upstream(module, version)
- except (ValueError, SpecFileError) as e:
- #print(bytes("ERROR: %s" % str(e), 'UTF-8'), file=stderr)
- stderr.write(bytes("ERROR: %s" % str(e), 'UTF-8'))
+ except (ValueError, SpecFileError) as exc:
+ #print(bytes("ERROR: %s" % str(exc), 'UTF-8'), file=stderr)
+ stderr.write(bytes("ERROR: %s" % str(exc), 'UTF-8'))
if options.mail:
_send_reply_mail(stdout, msg, options.mail, error=True)
@@ -1963,16 +1963,12 @@ def main():
func=cmd_check_prep
)
- subparser = subparsers.add_parser('clean-spec', help='clean specfile')
+ subparser = subparsers.add_parser('check-spec', help='check if spec file is ok')
subparser.add_argument("package", help="Package name", nargs='*')
- subparser.add_argument("-d", "-s", action="store_true", dest="doit", help="submit the changes")
- subparser.add_argument("-f", "--force", action="store_true")
subparser.add_argument("-a", "--all", action="store_true", dest="all",
help="checkout all Downstream packages")
- subparser.add_argument("--convert", action="store_true", dest="convert_br",
- help="convert -buildrequirements to perl/pkgconfig if possible")
subparser.set_defaults(
- func=cmd_clean_spec, doit=False, convert_br=False, all=False, force=False
+ func=cmd_check_spec
)
subparser = subparsers.add_parser('check-version', help='check if spec version and downstream version match')
@@ -1980,12 +1976,21 @@ def main():
func=cmd_check_version
)
- subparser = subparsers.add_parser('check-spec', help='check if spec file is ok')
+ subparser = subparsers.add_parser('clean-spec', help='clean specfile')
subparser.add_argument("package", help="Package name", nargs='*')
+ subparser.add_argument("-d", "-s", action="store_true", dest="doit", help="submit the changes")
+ subparser.add_argument("-f", "--force", action="store_true")
subparser.add_argument("-a", "--all", action="store_true", dest="all",
help="checkout all Downstream packages")
+ subparser.add_argument("--convert", action="store_true", dest="convert_br",
+ help="convert -buildrequirements to perl/pkgconfig if possible")
subparser.set_defaults(
- func=cmd_check_spec
+ func=cmd_clean_spec, doit=False, convert_br=False, all=False, force=False
+ )
+
+ subparser = subparsers.add_parser('cleanup', help='cleanup pkg directory')
+ subparser.set_defaults(
+ func=cmd_cleanup
)
subparser = subparsers.add_parser('co', help='checkout all GNOME packages')
@@ -2018,22 +2023,6 @@ def main():
func=cmd_group_owner
)
- subparser = subparsers.add_parser('rebuild', help='increase release')
- subparser.add_argument("package", help="Package name", nargs="*")
- subparser.add_argument("-m", "--reason", dest="reason", required=True, help="Reason for the rebuild")
- subparser.add_argument("-f", "--force", action="store_true", dest="force",
- help="Override warnings, just do it")
- subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream",
- help="Package name reflects the upstream name")
- subparser.add_argument("-s", "--submit", action="store_true", dest="submit",
- help="Commit changes and submit")
- subparser.add_argument("--no-submit", action="store_false", dest="submit",
- help="Do not commit changes and submit")
- subparser.set_defaults(
- func=cmd_new_release, submit=argparse.SUPPRESS, upstream=False,
- force=False
- )
-
subparser = subparsers.add_parser('increase', help='increase version number')
subparser.add_argument("package", help="Package name")
subparser.add_argument("version", help="Version number")
@@ -2070,11 +2059,6 @@ def main():
func=cmd_ls, upstream=False, show_version=False, diff=False
)
- subparser = subparsers.add_parser('cleanup', help='cleanup pkg directory')
- subparser.set_defaults(
- func=cmd_cleanup
- )
-
subparser = subparsers.add_parser('patches', help='list all GNOME patches')
subparser.add_argument("-p", "--path", action="store_true", dest="path",
help="Show full path to patch")
@@ -2082,6 +2066,22 @@ def main():
func=cmd_patches, path=False
)
+ subparser = subparsers.add_parser('rebuild', help='increase release')
+ subparser.add_argument("package", help="Package name", nargs="*")
+ subparser.add_argument("-m", "--reason", dest="reason", required=True, help="Reason for the rebuild")
+ subparser.add_argument("-f", "--force", action="store_true", dest="force",
+ help="Override warnings, just do it")
+ subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream",
+ help="Package name reflects the upstream name")
+ subparser.add_argument("-s", "--submit", action="store_true", dest="submit",
+ help="Commit changes and submit")
+ subparser.add_argument("--no-submit", action="store_false", dest="submit",
+ help="Do not commit changes and submit")
+ subparser.set_defaults(
+ func=cmd_new_release, submit=argparse.SUPPRESS, upstream=False,
+ force=False
+ )
+
if len(sys.argv) == 1:
parser.print_help()
sys.exit(2)
@@ -2107,8 +2107,8 @@ def main():
except EOFError:
print('EOF')
sys.exit(1)
- except IOError as e:
- if e.errno != errno.EPIPE:
+ except IOError as exc:
+ if exc.errno != errno.EPIPE:
raise
sys.exit(0)