summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2011-04-04 10:38:40 +0200
committerJulian Andres Klode <jak@debian.org>2011-04-04 10:38:40 +0200
commit79cb66e2737c3bfd87a5960f175f6281b1565190 (patch)
treea72387b746f314a3765345a7a9811861b7fa7b88 /apt
parent71e419a088092a3f6c62836d7bd09f952133fb3f (diff)
downloadpython-apt-79cb66e2737c3bfd87a5960f175f6281b1565190.tar.gz
* apt/cache.py, apt/package.py:
- Add architecture property to apt.Package (LP: #703472) - Change apt.Package.name to use get_fullname(pretty=True) (LP: #740072)
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py8
-rw-r--r--apt/package.py42
2 files changed, 41 insertions, 9 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 4b917236..40fe40a9 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -132,6 +132,9 @@ class Cache(object):
self._sorted_set = None
self._weakref.clear()
+ self._have_multi_arch = bool(apt_pkg.config.value_list("APT::" +
+ "Architectures"))
+
progress.op = _("Building data structures")
i = last = 0
size = len(self._cache.packages)
@@ -141,7 +144,10 @@ class Cache(object):
last = i
# drop stuff with no versions (cruft)
if pkg.has_versions:
- self._set.add(pkg.name)
+ self._set.add(pkg.get_fullname(pretty=True))
+ assert self._cache[pkg.get_fullname(pretty=True)] is not None
+ if self._have_multi_arch:
+ self._set.add(pkg.get_fullname(pretty=False))
i += 1
diff --git a/apt/package.py b/apt/package.py
index f16ac2a4..d7d5d167 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -374,9 +374,9 @@ class Version(object):
def source_name(self):
"""Return the name of the source package."""
try:
- return self._records.source_pkg or self.package.name
+ return self._records.source_pkg or self.package.shortname
except IndexError:
- return self.package.name
+ return self.package.shortname
@property
def source_version(self):
@@ -549,7 +549,7 @@ class Version(object):
dsc = None
record = self._records
- source_name = record.source_pkg or self.package.name
+ source_name = record.source_pkg or self.package.shortname
source_version = record.source_ver or self._cand.ver_str
source_lookup = src.lookup(source_name)
@@ -674,7 +674,8 @@ class Package(object):
self._changelog = "" # Cached changelog
def __repr__(self):
- return '<Package: name:%r id:%r>' % (self._pkg.name, self._pkg.id)
+ return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name,
+ self._pkg.architecture, self._pkg.id)
def candidate(self):
"""Return the candidate version of the package.
@@ -706,7 +707,30 @@ class Package(object):
@property
def name(self):
- """Return the name of the package."""
+ """Return the name of the package, possibly including architecture.
+
+ If the package is not part of the system's preferred architecture,
+ return the same as :attr:`fullname`, otherwise return the same
+ as :attr:`shortname`
+
+ .. versionchanged:: 0.7.100.3
+ As part of multi-arch, this field now may include architecture
+ information.
+ """
+ return self._pkg.get_fullname(True)
+
+ @property
+ def fullname(self):
+ """Return the name of the package, including architecture.
+
+ .. versionadded:: 0.7.100.3"""
+ return self._pkg.get_fullname(False)
+
+ @property
+ def shortname(self):
+ """Return the name of the package, without architecture.
+
+ .. versionadded:: 0.7.100.3"""
return self._pkg.name
@property
@@ -757,13 +781,15 @@ class Package(object):
"""
return getattr(self.installed, 'dependencies', [])
- @DeprecatedProperty
def architecture(self):
"""Return the Architecture of the package.
- .. deprecated:: 0.7.9
+ .. versionchanged:: 0.7.100.3
+ This is now the package's architecture in the multi-arch sense,
+ previously it was the architecture of the candidate version
+ and deprecated.
"""
- return getattr(self.candidate, "architecture", None)
+ return self._pkg.architecture
@DeprecatedProperty
def candidateDownloadable(self): #pylint: disable-msg=C0103