diff --git a/src/rpmquery/querylayeriniso.py b/src/rpmquery/querylayeriniso.py index 688db1d3d7082d79df88db631ac2ecf6363eaf07..0f4962e954d54836c9759e92d1da2c1200da6902 100644 --- a/src/rpmquery/querylayeriniso.py +++ b/src/rpmquery/querylayeriniso.py @@ -30,7 +30,7 @@ class QueryLayerInIso(RpmQuery): def __init__(self,rpm,iso): self._rpm = rpm self._iso = iso - self._get_isofiles() + self._isofiles = ISOUtils.parse_iso_repofile(self.iso) @classmethod def run(cls,args): @@ -69,13 +69,9 @@ class QueryLayerInIso(RpmQuery): repo.repomd_fn, repo.primary_fn,repo.filelists_fn = self._isofiles sack.load_repo(repo,load_filelists=True) q = hawkey.Query(sack) - req_l = [] req_objs = q.filter(provides=rpminfo.requires) - for req_obj in req_objs: - req_pkgname = req_obj.name - req_l.append(req_pkgname) - req_l = list(set(req_l)) - return req_l + req_l = {req_obj.name for req_obj in req_objs} + return list(req_l) def _get_isopkgs_layer(self): """ @@ -84,13 +80,7 @@ class QueryLayerInIso(RpmQuery): res (dict) """ isodepobj = ISODepParse(self._isofiles) - res = AlgLayer.run(isodepobj, BaseConfig.LAYERDATA) - return res - - def _get_isofiles(self): - """获取iso元数据 - """ - self._isofiles = ISOUtils.parse_iso_repofile(self.iso) + return AlgLayer.run(isodepobj, BaseConfig.LAYERDATA) @classmethod def check(cls,args): @@ -103,8 +93,7 @@ class QueryLayerInIso(RpmQuery): iso = args[1] if RpmCheck.check(rpm) and IsoCheck.check(iso): return True - else: - return False + return False @property def rpm(self): diff --git a/src/rpmquery/querylayerinlocal.py b/src/rpmquery/querylayerinlocal.py index df80652de1068cbc4fb479cc1f8bcb26a9fa5e81..cb29d780b725dea6ce60ec4c7ff52942bcf0603b 100644 --- a/src/rpmquery/querylayerinlocal.py +++ b/src/rpmquery/querylayerinlocal.py @@ -67,13 +67,9 @@ class QueryLayerInLocal(RpmQuery): sack = hawkey.Sack() sack.load_system_repo(build_cache=False) q = hawkey.Query(sack) - req_l = [] req_objs = q.filter(provides=rpminfo.requires) - for req_obj in req_objs: - req_pkgname = req_obj.name - req_l.append(req_pkgname) - req_l = list(set(req_l)) - return req_l + req_l = {req_obj.name for req_obj in req_objs} + return list(req_l) def _get_localpkgs_layer(self): """ @@ -82,8 +78,7 @@ class QueryLayerInLocal(RpmQuery): res (dict) """ localdepobj = LocalInstalledDepParse() - res = AlgLayer.run(localdepobj, BaseConfig.LAYERDATA) - return res + return AlgLayer.run(localdepobj, BaseConfig.LAYERDATA) @classmethod def check(cls,rpm):