From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QkMUN-0004iV-63 for garchives@archives.gentoo.org; Fri, 22 Jul 2011 20:38:27 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B61CE21C207; Fri, 22 Jul 2011 20:38:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7401321C207 for ; Fri, 22 Jul 2011 20:38:19 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DFF791B4016 for ; Fri, 22 Jul 2011 20:38:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id BC4CA8003D for ; Fri, 22 Jul 2011 20:38:17 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <53bce8a6d96f04acc97871712c107387d14f45e6.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/_dyn_libs/LinkageMapELF.py X-VCS-Directories: pym/portage/util/_dyn_libs/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 53bce8a6d96f04acc97871712c107387d14f45e6 Date: Fri, 22 Jul 2011 20:38:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 0fb79ebed5833127bd8f3f74adceac63 commit: 53bce8a6d96f04acc97871712c107387d14f45e6 Author: Zac Medico gentoo org> AuthorDate: Fri Jul 22 20:38:04 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jul 22 20:38:04 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D53bce8a6 LinkageMapELF: use a class for _obj_properies This simplifies the interface, avoiding the need for hardcoded indexes and making it easy to add new attributes. --- pym/portage/util/_dyn_libs/LinkageMapELF.py | 42 ++++++++++++++++++++-= ------ 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/ut= il/_dyn_libs/LinkageMapELF.py index 49a7d35..90d43e7 100644 --- a/pym/portage/util/_dyn_libs/LinkageMapELF.py +++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py @@ -26,6 +26,25 @@ class LinkageMapELF(object): _soname_map_class =3D slot_dict_class( ("consumers", "providers"), prefix=3D"") =20 + class _obj_properies_class(object): + + __slots__ =3D ("arch", "needed", "runpaths", "soname", "alt_paths",) + + def __init__(self, arch, needed, runpaths, soname, alt_paths): + self.arch =3D arch + self.needed =3D needed + self.runpaths =3D runpaths + self.soname =3D soname + self.alt_paths =3D alt_paths + + def __iter__(self): + """Backward compatibility with 5-tuples.""" + yield self.arch + yield self.needed + yield self.runpaths + yield self.soname + yield self.alt_paths + def __init__(self, vardbapi): self._dbapi =3D vardbapi self._root =3D self._dbapi.settings['ROOT'] @@ -295,10 +314,11 @@ class LinkageMapELF(object): myprops =3D obj_properties.get(obj_key) if myprops is None: indexed =3D False - myprops =3D (arch, needed, path, soname, []) + myprops =3D self._obj_properies_class( + arch, needed, path, soname, []) obj_properties[obj_key] =3D myprops # All object paths are added into the obj_properties tuple. - myprops[4].append(obj) + myprops.alt_paths.append(obj) =20 # Don't index the same file more that once since only one # set of data can be correct and therefore mixing data @@ -430,7 +450,7 @@ class LinkageMapELF(object): writemsg_level( _("Found provider outside of findProviders:") + \ (" %s -> %s %s\n" % (os.path.join(directory, soname), - self._obj_properties[cachedKey][4], libraries)), + self._obj_properties[cachedKey].alt_paths, libraries)), level=3Dlogging.DEBUG, noiselevel=3D-1) # A valid library has been found, so there is no need to @@ -516,7 +536,7 @@ class LinkageMapELF(object): if obj_key not in self._obj_properties: raise KeyError("%s (%s) not in object list" % (obj_key, obj)) basename =3D os.path.basename(obj) - soname =3D self._obj_properties[obj_key][3] + soname =3D self._obj_properties[obj_key].soname return len(basename) < len(soname) and \ basename.endswith(".so") and \ soname.startswith(basename[:-3]) @@ -537,7 +557,7 @@ class LinkageMapELF(object): for arch_map in self._libs.values(): for soname_map in arch_map.values(): for obj_key in soname_map.providers: - rValue.extend(self._obj_properties[obj_key][4]) + rValue.extend(self._obj_properties[obj_key].alt_paths) return rValue =20 def getSoname(self, obj): @@ -556,10 +576,10 @@ class LinkageMapELF(object): obj_key =3D obj if obj_key not in self._obj_properties: raise KeyError("%s not in object list" % obj_key) - return self._obj_properties[obj_key][3] + return self._obj_properties[obj_key].soname if obj not in self._obj_key_cache: raise KeyError("%s not in object list" % obj) - return self._obj_properties[self._obj_key_cache[obj]][3] + return self._obj_properties[self._obj_key_cache[obj]].soname =20 def findProviders(self, obj): """ @@ -608,7 +628,7 @@ class LinkageMapELF(object): # For each potential provider of the soname, add it to rValue if it # resides in the obj's runpath. for provider_key in self._libs[arch][soname].providers: - providers =3D self._obj_properties[provider_key][4] + providers =3D self._obj_properties[provider_key].alt_paths for provider in providers: if self._path_key(os.path.dirname(provider)) in path_keys: rValue[soname].add(provider) @@ -667,7 +687,7 @@ class LinkageMapELF(object): obj_key =3D obj if obj_key not in self._obj_properties: raise KeyError("%s not in object list" % obj_key) - objs =3D self._obj_properties[obj_key][4] + objs =3D self._obj_properties[obj_key].alt_paths else: objs =3D set([obj]) obj_key =3D self._obj_key(obj) @@ -679,7 +699,7 @@ class LinkageMapELF(object): # other version, this lib will be shadowed and won't # have any consumers. if not isinstance(obj, self._ObjectKey): - soname =3D self._obj_properties[obj_key][3] + soname =3D self._obj_properties[obj_key].soname soname_link =3D os.path.join(self._root, os.path.dirname(obj).lstrip(os.path.sep), soname) obj_path =3D os.path.join(self._root, obj.lstrip(os.sep)) @@ -706,7 +726,7 @@ class LinkageMapELF(object): if exclude_providers is not None: relevant_dir_keys =3D set() for provider_key in soname_node.providers: - provider_objs =3D self._obj_properties[provider_key][4] + provider_objs =3D self._obj_properties[provider_key].alt_paths for p in provider_objs: provider_excluded =3D False for excluded_provider_isowner in exclude_providers: