diff options
author | 2016-02-03 17:09:48 -0800 | |
---|---|---|
committer | 2016-02-03 17:10:46 -0800 | |
commit | 52839f10133613333acbd0d1e6f8bffa74af3f70 (patch) | |
tree | 5bcc3dc5961e8c5229f8f416938fa3b946297e80 /thicken-manifests.py | |
parent | thicken-manifests: another tweak from dwfreed. (diff) | |
download | mastermirror-scripts-52839f10133613333acbd0d1e6f8bffa74af3f70.tar.gz mastermirror-scripts-52839f10133613333acbd0d1e6f8bffa74af3f70.tar.bz2 mastermirror-scripts-52839f10133613333acbd0d1e6f8bffa74af3f70.zip |
thicken-manifests: Fixup pylint.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'thicken-manifests.py')
-rwxr-xr-x | thicken-manifests.py | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/thicken-manifests.py b/thicken-manifests.py index 014a2ee..17a19e3 100755 --- a/thicken-manifests.py +++ b/thicken-manifests.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# pylint: disable=line-too-long,missing-docstring,invalid-name +# vim:noet sts=4 ts=4 # Copyright 2015 Doug Freed (dwfreed) # # - Acquire local copy of repo/gentoo (.git directory not required) @@ -38,8 +40,7 @@ dir_contents = collections.defaultdict(list) def gpg_sign(filename): gpgcmd = portage_settings.get("PORTAGE_GPG_SIGNING_COMMAND") if gpgcmd in [None, '']: - raise portage.exception.MissingParameter( - "PORTAGE_GPG_SIGNING_COMMAND is unset! Is make.globals missing?") + raise portage.exception.MissingParameter("PORTAGE_GPG_SIGNING_COMMAND is unset! Is make.globals missing?") if "${PORTAGE_GPG_KEY}" in gpgcmd and "PORTAGE_GPG_KEY" not in portage_settings: raise portage.exception.MissingParameter("PORTAGE_GPG_KEY is unset!") if "${PORTAGE_GPG_DIR}" in gpgcmd: @@ -48,9 +49,7 @@ def gpg_sign(filename): else: portage_settings["PORTAGE_GPG_DIR"] = os.path.expanduser(portage_settings["PORTAGE_GPG_DIR"]) if not os.access(portage_settings["PORTAGE_GPG_DIR"], os.X_OK): - raise portage.exception.InvalidLocation( - "Unable to access directory: PORTAGE_GPG_DIR='%s'" % - portage_settings["PORTAGE_GPG_DIR"]) + raise portage.exception.InvalidLocation("Unable to access directory: PORTAGE_GPG_DIR='%s'" % portage_settings["PORTAGE_GPG_DIR"]) gpgvars = {"FILE": filename} for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"): v = portage_settings.get(k) @@ -58,7 +57,7 @@ def gpg_sign(filename): gpgvars[k] = v gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars) gpgcmd = portage.util.shlex_split(gpgcmd) - gpgcmd = [portage._unicode_encode(arg, encoding=portage._encodings['fs'], errors='strict') for arg in gpgcmd] + gpgcmd = [portage._unicode_encode(arg, encoding=portage._encodings['fs'], errors='strict') for arg in gpgcmd] # pylint: disable=protected-access return_code = subprocess.call(gpgcmd) if return_code == os.EX_OK: @@ -68,9 +67,9 @@ def gpg_sign(filename): def worker_init(): - global portage_settings, portage_portdbapi - portage_settings = portage.config(clone=portage.settings) - portage_portdbapi = portage.portdbapi(portage_settings) + global portage_settings, portage_portdbapi # pylint: disable=global-statement + portage_settings = portage.config(clone=portage.settings) # pylint: disable=no-member + portage_portdbapi = portage.portdbapi(portage_settings) # pylint: disable=no-member def maybe_thicken_manifest(pkg_dir): @@ -83,20 +82,20 @@ def maybe_thicken_manifest(pkg_dir): newest_mtime = manifest_mtime manifest_entries = [] for root in pkg_dir, os.path.join(pkg_dir, 'files'): - for file in dir_contents[root]: - if file == 'Manifest': + for filename in dir_contents[root]: + if filename == 'Manifest': continue - file_mtime = math.floor(os.stat(os.path.join(root, file)).st_mtime) + file_mtime = math.floor(os.stat(os.path.join(root, filename)).st_mtime) if file_mtime > newest_mtime: newest_mtime = file_mtime if os.path.split(root)[1] == 'files': - manifest_entries.append('AUX ' + file) - elif file.endswith('.ebuild'): - manifest_entries.append('EBUILD ' + file) + manifest_entries.append('AUX ' + filename) + elif filename.endswith('.ebuild'): + manifest_entries.append('EBUILD ' + filename) else: - manifest_entries.append('MISC ' + file) + manifest_entries.append('MISC ' + filename) if newest_mtime == manifest_mtime: try: @@ -137,10 +136,9 @@ def maybe_thicken_manifest(pkg_dir): def main(): - global logger, args, dir_contents + global logger, args, dir_contents # pylint: disable=global-statement parser = argparse.ArgumentParser(description='Thicken ebuild manifests as needed') - parser.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int, - help='Number of parallel jobs to run; default: number of CPUs') + parser.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int, help='Number of parallel jobs to run; default: number of CPUs') parser.add_argument('-s', '--sign', action='store_true', help='Sign manifests with GPG') parser.add_argument('location', nargs='?', default='.', help='The location to thicken manifests in; default: .') args = parser.parse_args() @@ -161,22 +159,22 @@ location = %s pkg_dirs = [] for root, subdirectories, files in os.walk('.'): if root == '.': - for dir in ('eclass', 'licenses', 'metadata', 'profiles', 'scripts', '.git'): - if dir in subdirectories: - subdirectories.remove(dir) + for dirname in ('eclass', 'licenses', 'metadata', 'profiles', 'scripts', '.git'): + if dirname in subdirectories: + subdirectories.remove(dirname) if (not subdirectories or subdirectories == ['files']) and 'metadata.xml' in files: pkg_dirs.append(root[2:]) dir_contents[root[2:]] = files elif os.path.split(root)[1] == 'files' and 'metadata.xml' not in files: dir_contents[root[2:]] = files - for dir in subdirectories[:]: - subdirectories.remove(dir) + for dirname in subdirectories[:]: + subdirectories.remove(dirname) os.chdir(root) for root2, subdirectories2, files2 in os.walk('.'): if root2 != '.': - for file in files2: - dir_contents[root[2:]].append(os.path.join(root2[2:], file)) + for filename in files2: + dir_contents[root[2:]].append(os.path.join(root2[2:], filename)) os.chdir(args.location) pkg_dirs.sort() |