From 65697a7526899b299964422f3341efe840a895ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 21 Apr 2016 13:42:08 +0200 Subject: [PATCH] [pkgset] Clean up Koji source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove unused imports and variables * Simplify code where possible * Break too long lines Signed-off-by: Lubomír Sedlář --- pungi/phases/pkgset/sources/source_koji.py | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index bd3feda9..d6a8768c 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -19,8 +19,6 @@ import os import cPickle as pickle import json -import koji - import pungi.wrappers.kojiwrapper import pungi.phases.pkgset.pkgsets from pungi.arch import get_valid_arches @@ -59,18 +57,17 @@ class PkgsetSourceKoji(pungi.phases.pkgset.source.PkgsetSourceBase): compose = self.compose koji_profile = compose.conf["koji_profile"] self.koji_wrapper = pungi.wrappers.kojiwrapper.KojiWrapper(koji_profile) - path_prefix = self.koji_wrapper.koji_module.config.topdir.rstrip("/") + "/" # must contain trailing '/' + # path prefix must contain trailing '/' + path_prefix = self.koji_wrapper.koji_module.config.topdir.rstrip("/") + "/" package_sets = get_pkgset_from_koji(self.compose, self.koji_wrapper, path_prefix) return (package_sets, path_prefix) def get_pkgset_from_koji(compose, koji_wrapper, path_prefix): - koji_proxy = koji_wrapper.koji_proxy event_info = get_koji_event_info(compose, koji_wrapper) tag_info = get_koji_tag_info(compose, koji_wrapper) pkgset_global = populate_global_pkgset(compose, koji_wrapper, path_prefix, tag_info, event_info) -# get_extra_packages(compose, pkgset_global) package_sets = populate_arch_pkgsets(compose, path_prefix, pkgset_global) package_sets["global"] = pkgset_global @@ -83,12 +80,11 @@ def get_pkgset_from_koji(compose, koji_wrapper, path_prefix): def populate_global_pkgset(compose, koji_wrapper, path_prefix, compose_tag, event_id): - koji_proxy = koji_wrapper.koji_proxy - ALL_ARCHES = set(["src"]) + all_arches = set(["src"]) for arch in compose.get_arches(): is_multilib = is_arch_multilib(compose.conf, arch) arches = get_valid_arches(arch, is_multilib) - ALL_ARCHES.update(arches) + all_arches.update(arches) compose_tag = compose.conf["pkgset_koji_tag"] inherit = compose.conf.get("pkgset_koji_inherit", True) @@ -99,15 +95,15 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, compose_tag, even pkgset = pickle.load(open(global_pkgset_path, "r")) else: compose.log_info(msg) - pkgset = pungi.phases.pkgset.pkgsets.KojiPackageSet(koji_wrapper, compose.conf["sigkeys"], logger=compose._logger, arches=ALL_ARCHES) + pkgset = pungi.phases.pkgset.pkgsets.KojiPackageSet(koji_wrapper, compose.conf["sigkeys"], + logger=compose._logger, arches=all_arches) pkgset.populate(compose_tag, event_id, inherit=inherit) - f = open(global_pkgset_path, "w") - data = pickle.dumps(pkgset) - f.write(data) - f.close() + with open(global_pkgset_path, 'w') as f: + f.write(pickle.dumps(pkgset)) # write global package list - pkgset.save_file_list(compose.paths.work.package_list(arch="global"), remove_path_prefix=path_prefix) + pkgset.save_file_list(compose.paths.work.package_list(arch="global"), + remove_path_prefix=path_prefix) return pkgset