summaryrefslogtreecommitdiff
path: root/apt/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'apt/package.py')
-rw-r--r--apt/package.py505
1 files changed, 172 insertions, 333 deletions
diff --git a/apt/package.py b/apt/package.py
index dbaab320..57c89b35 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -19,34 +19,35 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Functionality related to packages."""
-import httplib
+from __future__ import print_function
+
+
import os
import sys
import re
import socket
import subprocess
-import urllib2
-import warnings
-try:
- from collections import Mapping, Sequence
-except ImportError:
- # (for Python < 2.6) pylint: disable-msg=C0103
- Sequence = Mapping = object
try:
- from collections import Sequence
+ from http.client import BadStatusLine
+ from urllib.error import HTTPError
+ from urllib.request import urlopen
except ImportError:
- Sequence = object
+ from httplib import BadStatusLine
+ from urllib2 import HTTPError, urlopen
+
+from collections import Mapping, Sequence
import apt_pkg
import apt.progress.text
from apt_pkg import gettext as _
-from apt.deprecation import (function_deprecated_by, AttributeDeprecatedBy,
- deprecated_args)
__all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record',
'Version', 'VersionList')
+if sys.version_info.major >= 3:
+ unicode = str
+
def _file_is_same(path, size, md5):
"""Return ``True`` if the file is the same."""
@@ -60,38 +61,77 @@ class FetchError(Exception):
class BaseDependency(object):
- """A single dependency.
-
- Attributes defined here:
- name - The name of the dependency
- relation - The relation (>,>=,==,<,<=,)
- version - The version depended on
- rawtype - The type of the dependendy (e.g. 'Recommends')
- pre_depend - Boolean value whether this is a pre-dependency.
- """
+ """A single dependency."""
class __dstr(str):
- """Helper to make > match >> and < match <<"""
+ """Compare helper for compatibility with old third-party code.
+
+ Old third-party code might still compare the relation with the
+ previously used relations (<<,<=,==,!=,>=,>>,) instead of the curently
+ used ones (<,<=,=,!=,>=,>,). This compare helper lets < match to <<,
+ > match to >> and = match to ==.
+ """
def __eq__(self, other):
- return str.__eq__(self, other) or str.__eq__(2 * self, other)
+ if str.__eq__(self, other):
+ return True
+ elif str.__eq__(self, '<'):
+ return str.__eq__('<<', other)
+ elif str.__eq__(self, '>'):
+ return str.__eq__('>>', other)
+ elif str.__eq__(self, '='):
+ return str.__eq__('==', other)
+ else:
+ return False
def __ne__(self, other):
- return str.__eq__(self, other) and str.__ne__(2 * self, other)
+ return not self.__eq__(other)
- def __init__(self, name, rel, ver, pre, rawtype=None):
- self.name = name
- self.relation = len(rel) == 1 and self.__dstr(rel) or rel
- self.version = ver
- self.pre_depend = pre
- self.rawtype = rawtype
+ def __init__(self, dep):
+ self._dep = dep # apt_pkg.Dependency
- def __repr__(self):
- return ('<BaseDependency: name:%r relation:%r version:%r preDepend:%r>'
- % (self.name, self.relation, self.version, self.pre_depend))
+ @property
+ def name(self):
+ """The name of the target package."""
+ return self._dep.target_pkg.name
+
+ @property
+ def relation(self):
+ """The relation (<, <=, !=, =, >=, >, ).
+
+ Note that the empty string is a valid string as well, if no version
+ is specified.
+ """
+ return self.__dstr(self._dep.comp_type)
- if apt_pkg._COMPAT_0_7:
- preDepend = AttributeDeprecatedBy('pre_depend')
+ @property
+ def version(self):
+ """The target version or an empty string.
+
+ Note that the version is only an empty string in case of an unversioned
+ dependency. In this case the relation is also an empty string.
+ """
+ return self._dep.target_ver
+
+ @property
+ def rawtype(self):
+ """Type of the dependency.
+
+ This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances',
+ 'PreDepends', 'Recommends', 'Replaces', 'Suggests'.
+
+ Additional types might be added in the future.
+ """
+ return self._dep.dep_type_untranslated
+
+ @property
+ def pre_depend(self):
+ """Whether this is a PreDepends."""
+ return self._dep.dep_type_untranslated == 'PreDepends'
+
+ def __repr__(self):
+ return ('<BaseDependency: name:%r relation:%r version:%r rawtype:%r>'
+ % (self.name, self.relation, self.version, self.rawtype))
class Dependency(list):
@@ -99,34 +139,29 @@ class Dependency(list):
Attributes defined here:
or_dependencies - The possible choices
+ rawtype - The type of the dependencies in the Or-group
"""
- def __init__(self, alternatives):
- super(Dependency, self).__init__()
- self.extend(alternatives)
+ def __init__(self, base_deps, rawtype):
+ super(Dependency, self).__init__(base_deps)
+ self._rawtype = rawtype
@property
def or_dependencies(self):
return self
-class DeprecatedProperty(property):
- """A property which gives DeprecationWarning on access.
+ @property
+ def rawtype(self):
+ """Type of the Or-group of dependency.
- This is only used for providing the properties in Package, which have been
- replaced by the ones in Version.
- """
+ This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances',
+ 'PreDepends', 'Recommends', 'Replaces', 'Suggests'.
- def __init__(self, fget=None, fset=None, fdel=None, doc=None):
- property.__init__(self, fget, fset, fdel, doc)
- self.__doc__ = (doc or fget.__doc__ or '')
+ Additional types might be added in the future.
- def __get__(self, obj, type_=None):
- if obj is not None:
- warnings.warn("Accessed deprecated property %s.%s, please see the "
- "Version class for alternatives." %
- ((obj.__class__.__name__ or type_.__name__),
- self.fget.__name__), DeprecationWarning, 2)
- return property.__get__(self, obj, type_)
+ .. versionadded:: 1.0.0
+ """
+ return self._rawtype
class Origin(object):
@@ -356,14 +391,14 @@ class Version(object):
try:
if not isinstance(dsc, unicode):
# Only convert where needed (i.e. Python 2.X)
- dsc = unicode(dsc, "utf-8")
+ dsc = dsc.decode("utf-8")
except UnicodeDecodeError as err:
return _("Invalid unicode in description for '%s' (%s). "
- "Please report.") % (self.package.name, err)
+ "Please report.") % (self.package.name, err)
lines = iter(dsc.split("\n"))
# Skip the first line, since its a duplication of the summary
- lines.next()
+ next(lines)
for raw_line in lines:
if raw_line.strip() == ".":
# The line is just line break
@@ -417,7 +452,7 @@ class Version(object):
"""
priority = 0
policy = self.package._pcache._depcache.policy
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
priority = max(priority, policy.get_priority(packagefile))
return priority
@@ -431,7 +466,14 @@ class Version(object):
return Record(self._records.record)
def get_dependencies(self, *types):
- """Return a list of Dependency objects for the given types."""
+ """Return a list of Dependency objects for the given types.
+
+ Multiple types can be specified. Possible types are:
+ 'Breaks', 'Conflicts', 'Depends', 'Enhances', 'PreDepends',
+ 'Recommends', 'Replaces', 'Suggests'
+
+ Additional types might be added in the future.
+ """
depends_list = []
depends = self._cand.depends_list
for type_ in types:
@@ -439,11 +481,8 @@ class Version(object):
for dep_ver_list in depends[type_]:
base_deps = []
for dep_or in dep_ver_list:
- base_deps.append(BaseDependency(dep_or.target_pkg.name,
- dep_or.comp_type, dep_or.target_ver,
- (type_ == "PreDepends"),
- rawtype=type_))
- depends_list.append(Dependency(base_deps))
+ base_deps.append(BaseDependency(dep_or))
+ depends_list.append(Dependency(base_deps, type_))
except KeyError:
pass
return depends_list
@@ -452,7 +491,7 @@ class Version(object):
def provides(self):
""" Return a list of names that this version provides."""
return [p[0] for p in self._cand.provides_list]
-
+
@property
def enhances(self):
"""Return the list of enhances for the package version."""
@@ -477,7 +516,7 @@ class Version(object):
def origins(self):
"""Return a list of origins for the package version."""
origins = []
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
origins.append(Origin(self.package, packagefile))
return origins
@@ -528,7 +567,7 @@ class Version(object):
.. versionadded:: 0.7.10
"""
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
indexfile = self.package._pcache._list.find_index(packagefile)
if indexfile:
yield indexfile.archive_uri(self._records.filename)
@@ -548,7 +587,7 @@ class Version(object):
.. versionadded:: 0.7.10
"""
try:
- return iter(self._uris()).next()
+ return next(iter(self._uris()))
except StopIteration:
return None
@@ -567,7 +606,7 @@ class Version(object):
base = os.path.basename(self._records.filename)
destfile = os.path.join(destdir, base)
if _file_is_same(destfile, self.size, self._records.md5_hash):
- print('Ignoring already existing file: %s' % destfile)
+ print(('Ignoring already existing file: %s' % destfile))
return os.path.abspath(destfile)
acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress())
acqfile = apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash,
@@ -616,7 +655,7 @@ class Version(object):
if type_ == 'dsc':
dsc = destfile
if _file_is_same(destfile, size, md5):
- print('Ignoring already existing file: %s' % destfile)
+ print(('Ignoring already existing file: %s' % destfile))
continue
files.append(apt_pkg.AcquireFile(acq, src.index.archive_uri(path),
md5, size, base, destfile=destfile))
@@ -625,7 +664,7 @@ class Version(object):
for item in acq.items:
if item.status != item.STAT_DONE:
raise FetchError("The item %r could not be fetched: %s" %
- (item.destfile, item.error_text))
+ (item.destfile, item.error_text))
if unpack:
outdir = src.package + '-' + apt_pkg.upstream_version(src.version)
@@ -657,8 +696,8 @@ class VersionList(Sequence):
"""
def __init__(self, package, slice_=None):
- self._package = package # apt.package.Package()
- self._versions = package._pkg.version_list # [apt_pkg.Version(), ...]
+ self._package = package # apt.package.Package()
+ self._versions = package._pkg.version_list # [apt_pkg.Version(), ...]
if slice_:
self._versions = self._versions[slice_]
@@ -683,7 +722,7 @@ class VersionList(Sequence):
return (Version(self._package, ver) for ver in self._versions)
def __contains__(self, item):
- if isinstance(item, Version): # Sequence interface
+ if isinstance(item, Version): # Sequence interface
item = item.version
# Dictionary interface.
for ver in self._versions:
@@ -726,8 +765,8 @@ class Package(object):
self._changelog = "" # Cached changelog
def __repr__(self):
- return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name,
- self._pkg.architecture, self._pkg.id)
+ return '<Package: name:%r architecture=%r id:%r>' % (
+ self._pkg.name, self._pkg.architecture, self._pkg.id)
def __lt__(self, other):
return self.name < other.name
@@ -769,6 +808,7 @@ class Package(object):
as :attr:`shortname`
.. versionchanged:: 0.7.100.3
+
As part of multi-arch, this field now may include architecture
information.
"""
@@ -806,36 +846,6 @@ class Package(object):
"""Return True if the package is an essential part of the system."""
return self._pkg.essential
- @DeprecatedProperty
- def installedVersion(self): #pylint: disable-msg=C0103
- """Return the installed version as string.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.installed, 'version', None)
-
- @DeprecatedProperty
- def candidateVersion(self): #pylint: disable-msg=C0103
- """Return the candidate version as string.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "version", None)
-
- @DeprecatedProperty
- def candidateDependencies(self): #pylint: disable-msg=C0103
- """Return a list of candidate dependencies.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "dependencies", None)
-
- @DeprecatedProperty
- def installedDependencies(self): #pylint: disable-msg=C0103
- """Return a list of installed dependencies.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'dependencies', [])
-
def architecture(self):
"""Return the Architecture of the package.
@@ -846,107 +856,11 @@ class Package(object):
"""
return self._pkg.architecture
- @DeprecatedProperty
- def candidateDownloadable(self): #pylint: disable-msg=C0103
- """Return ``True`` if the candidate is downloadable.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "downloadable", None)
-
- @DeprecatedProperty
- def installedDownloadable(self): #pylint: disable-msg=C0103
- """Return ``True`` if the installed version is downloadable.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'downloadable', False)
-
- @DeprecatedProperty
- def sourcePackageName(self): #pylint: disable-msg=C0103
- """Return the source package name as string.
-
- .. deprecated:: 0.7.9
- """
- try:
- return self.candidate._records.source_pkg or self._pkg.name
- except AttributeError:
- try:
- return self.installed._records.source_pkg or self._pkg.name
- except AttributeError:
- return self._pkg.name
-
- @DeprecatedProperty
- def homepage(self):
- """Return the homepage field as string.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "homepage", None)
-
@property
def section(self):
"""Return the section of the package."""
return self._pkg.section
- @DeprecatedProperty
- def priority(self):
- """Return the priority (of the candidate version).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "priority", None)
-
- @DeprecatedProperty
- def installedPriority(self): #pylint: disable-msg=C0103
- """Return the priority (of the installed version).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'priority', None)
-
- @DeprecatedProperty
- def summary(self):
- """Return the short description (one line summary).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "summary", None)
-
- @DeprecatedProperty
- def description(self):
- """Return the formatted long description.
-
- Return the formatted long description according to the Debian policy
- (Chapter 5.6.13).
- See http://www.debian.org/doc/debian-policy/ch-controlfields.html
- for more information.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "description", None)
-
- @DeprecatedProperty
- def rawDescription(self): #pylint: disable-msg=C0103
- """return the long description (raw).
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "raw_description", None)
-
- @DeprecatedProperty
- def candidateRecord(self): #pylint: disable-msg=C0103
- """Return the Record of the candidate version of the package.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "record", None)
-
- @DeprecatedProperty
- def installedRecord(self): #pylint: disable-msg=C0103
- """Return the Record of the candidate version of the package.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.installed, 'record', '')
-
# depcache states
@property
@@ -1007,39 +921,6 @@ class Package(object):
return self._pcache._depcache.is_auto_installed(self._pkg)
# sizes
- @DeprecatedProperty
- def packageSize(self): #pylint: disable-msg=C0103
- """Return the size of the candidate deb package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "size", None)
-
- @DeprecatedProperty
- def installedPackageSize(self): #pylint: disable-msg=C0103
- """Return the size of the installed deb package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'size', 0)
-
- @DeprecatedProperty
- def candidateInstalledSize(self): #pylint: disable-msg=C0103
- """Return the size of the candidate installed package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "installed_size", None)
-
- @DeprecatedProperty
- def installedSize(self): #pylint: disable-msg=C0103
- """Return the size of the currently installed package.
-
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'installed_size', 0)
-
@property
def installed_files(self):
"""Return a list of files installed by the package.
@@ -1047,7 +928,7 @@ class Package(object):
Return a list of unicode names of the files which have
been installed by this package
"""
- for name in self.shortname, self.fullname:
+ for name in self.name, self.fullname:
path = "/var/lib/dpkg/info/%s.list" % name
try:
with open(path, "rb") as file_list:
@@ -1100,10 +981,10 @@ class Package(object):
src_section = "main"
# use the section of the candidate as a starting point
section = self.candidate.section
-
+
# get the source version
src_ver = self.candidate.source_version
-
+
try:
# try to get the source version of the pkg, this differs
# for some (e.g. libnspr4 on ubuntu)
@@ -1160,7 +1041,7 @@ class Package(object):
if cancel_lock and cancel_lock.isSet():
return u""
# FIXME: python3.2: Should be closed manually
- changelog_file = urllib2.urlopen(uri)
+ changelog_file = urlopen(uri)
# do only get the lines that are new
changelog = u""
regexp = "^%s \((.*)\)(.*)$" % (re.escape(src_pkg))
@@ -1189,7 +1070,7 @@ class Package(object):
changelog_ver = changelog_ver.split(":", 1)[1]
if (installed and apt_pkg.version_compare(
- changelog_ver, installed) <= 0):
+ changelog_ver, installed) <= 0):
break
# EOF (shouldn't really happen)
changelog += line
@@ -1201,29 +1082,25 @@ class Package(object):
changelog = changelog.decode("utf-8")
self._changelog = changelog
- except urllib2.HTTPError:
- res = _("The list of changes is not available yet.\n\n"
- "Please use http://launchpad.net/ubuntu/+source/%s/"
- "%s/+changelog\n"
- "until the changes become available or try again "
- "later.") % (src_pkg, src_ver)
+ except HTTPError:
+ if self.candidate.origins[0].origin == "Ubuntu":
+ res = _("The list of changes is not available yet.\n\n"
+ "Please use "
+ "http://launchpad.net/ubuntu/+source/%s/"
+ "%s/+changelog\n"
+ "until the changes become available or try again "
+ "later.") % (src_pkg, src_ver)
+ else:
+ res = _("The list of changes is not available")
return res if isinstance(res, unicode) else res.decode("utf-8")
- except (IOError, httplib.BadStatusLine):
+ except (IOError, BadStatusLine):
res = _("Failed to download the list of changes. \nPlease "
- "check your Internet connection.")
+ "check your Internet connection.")
return res if isinstance(res, unicode) else res.decode("utf-8")
finally:
socket.setdefaulttimeout(timeout)
return self._changelog
- @DeprecatedProperty
- def candidateOrigin(self): #pylint: disable-msg=C0103
- """Return a list of `Origin()` objects for the candidate version.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "origins", None)
-
@property
def versions(self):
"""Return a VersionList() object for all available versions.
@@ -1242,6 +1119,11 @@ class Package(object):
"""Return True if the installed package is broken."""
return self._pcache._depcache.is_now_broken(self._pkg)
+ @property
+ def has_config_files(self):
+ """Checks whether the package is is the config-files state."""
+ return self. _pkg.current_state == apt_pkg.CURSTATE_CONFIG_FILES
+
# depcache actions
def mark_keep(self):
@@ -1250,7 +1132,6 @@ class Package(object):
self._pcache._depcache.mark_keep(self._pkg)
self._pcache.cache_post_change()
- @deprecated_args
def mark_delete(self, auto_fix=True, purge=False):
"""Mark a package for deletion.
@@ -1272,7 +1153,6 @@ class Package(object):
fix.resolve()
self._pcache.cache_post_change()
- @deprecated_args
def mark_install(self, auto_fix=True, auto_inst=True, from_user=True):
"""Mark a package for install.
@@ -1297,11 +1177,12 @@ class Package(object):
fixer.resolve(True)
self._pcache.cache_post_change()
- def mark_upgrade(self):
+ def mark_upgrade(self, from_user=True):
"""Mark a package for upgrade."""
if self.is_upgradable:
- from_user = not self._pcache._depcache.is_auto_installed(self._pkg)
+ auto = self.is_auto_installed
self.mark_install(from_user=from_user)
+ self.mark_auto(auto)
else:
# FIXME: we may want to throw a exception here
sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: "
@@ -1328,103 +1209,61 @@ class Package(object):
self._pcache._depcache.commit(fprogress, iprogress)
- if not apt_pkg._COMPAT_0_7:
- del installedVersion
- del candidateVersion
- del candidateDependencies
- del installedDependencies
- del architecture
- del candidateDownloadable
- del installedDownloadable
- del sourcePackageName
- del homepage
- del priority
- del installedPriority
- del summary
- del description
- del rawDescription
- del candidateRecord
- del installedRecord
- del packageSize
- del installedPackageSize
- del candidateInstalledSize
- del installedSize
- del candidateOrigin
- else:
- markedInstalled = AttributeDeprecatedBy('marked_installed')
- markedInstall = AttributeDeprecatedBy('marked_install')
- markedUpgrade = AttributeDeprecatedBy('marked_upgrade')
- markedDelete = AttributeDeprecatedBy('marked_delete')
- markedKeep = AttributeDeprecatedBy('marked_keep')
- markedDowngrade = AttributeDeprecatedBy('marked_downgrade')
- markedReinstall = AttributeDeprecatedBy('marked_reinstall')
- isInstalled = AttributeDeprecatedBy('is_installed')
- isUpgradable = AttributeDeprecatedBy('is_upgradable')
- isAutoRemovable = AttributeDeprecatedBy('is_auto_removable')
- installedFiles = AttributeDeprecatedBy('installed_files')
- getChangelog = function_deprecated_by(get_changelog)
- markDelete = function_deprecated_by(mark_delete)
- markInstall = function_deprecated_by(mark_install)
- markKeep = function_deprecated_by(mark_keep)
- markUpgrade = function_deprecated_by(mark_upgrade)
-
-
def _test():
"""Self-test."""
- print "Self-test for the Package modul"
+ print("Self-test for the Package modul")
import random
apt_pkg.init()
progress = apt.progress.text.OpProgress()
cache = apt.Cache(progress)
pkg = cache["apt-utils"]
- print "Name: %s " % pkg.name
- print "ID: %s " % pkg.id
- print "Priority (Candidate): %s " % pkg.candidate.priority
- print "Priority (Installed): %s " % pkg.installed.priority
- print "Installed: %s " % pkg.installed.version
- print "Candidate: %s " % pkg.candidate.version
- print "CandidateDownloadable: %s" % pkg.candidate.downloadable
- print "CandidateOrigins: %s" % pkg.candidate.origins
- print "SourcePkg: %s " % pkg.candidate.source_name
- print "Section: %s " % pkg.section
- print "Summary: %s" % pkg.candidate.summary
- print "Description (formatted) :\n%s" % pkg.candidate.description
- print "Description (unformatted):\n%s" % pkg.candidate.raw_description
- print "InstalledSize: %s " % pkg.candidate.installed_size
- print "PackageSize: %s " % pkg.candidate.size
- print "Dependencies: %s" % pkg.installed.dependencies
- print "Recommends: %s" % pkg.installed.recommends
+ print("Name: %s " % pkg.name)
+ print("ID: %s " % pkg.id)
+ print("Priority (Candidate): %s " % pkg.candidate.priority)
+ print("Priority (Installed): %s " % pkg.installed.priority)
+ print("Installed: %s " % pkg.installed.version)
+ print("Candidate: %s " % pkg.candidate.version)
+ print("CandidateDownloadable: %s" % pkg.candidate.downloadable)
+ print("CandidateOrigins: %s" % pkg.candidate.origins)
+ print("SourcePkg: %s " % pkg.candidate.source_name)
+ print("Section: %s " % pkg.section)
+ print("Summary: %s" % pkg.candidate.summary)
+ print("Description (formatted) :\n%s" % pkg.candidate.description)
+ print("Description (unformatted):\n%s" % pkg.candidate.raw_description)
+ print("InstalledSize: %s " % pkg.candidate.installed_size)
+ print("PackageSize: %s " % pkg.candidate.size)
+ print("Dependencies: %s" % pkg.installed.dependencies)
+ print("Recommends: %s" % pkg.installed.recommends)
for dep in pkg.candidate.dependencies:
- print ",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation,
- o.pre_depend) for o in dep.or_dependencies)
- print "arch: %s" % pkg.candidate.architecture
- print "homepage: %s" % pkg.candidate.homepage
- print "rec: ", pkg.candidate.record
-
+ print(",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation,
+ o.pre_depend) for o in dep.or_dependencies))
+ print("arch: %s" % pkg.candidate.architecture)
+ print("homepage: %s" % pkg.candidate.homepage)
+ print("rec: ", pkg.candidate.record)
- print cache["2vcard"].get_changelog()
+ print(cache["2vcard"].get_changelog())
for i in True, False:
- print "Running install on random upgradable pkgs with AutoFix: %s " % i
+ print("Running install on random upgradable pkgs with AutoFix: ", i)
for pkg in cache:
if pkg.is_upgradable:
if random.randint(0, 1) == 1:
pkg.mark_install(i)
- print "Broken: %s " % cache._depcache.broken_count
- print "InstCount: %s " % cache._depcache.inst_count
+ print("Broken: %s " % cache._depcache.broken_count)
+ print("InstCount: %s " % cache._depcache.inst_count)
- print
+ print()
# get a new cache
for i in True, False:
- print "Randomly remove some packages with AutoFix: %s" % i
+ print("Randomly remove some packages with AutoFix: %s" % i)
cache = apt.Cache(progress)
for name in cache.keys():
if random.randint(0, 1) == 1:
try:
cache[name].mark_delete(i)
except SystemError:
- print "Error trying to remove: %s " % name
- print "Broken: %s " % cache._depcache.broken_count
- print "DelCount: %s " % cache._depcache.del_count
+ print("Error trying to remove: %s " % name)
+ print("Broken: %s " % cache._depcache.broken_count)
+ print("DelCount: %s " % cache._depcache.del_count)
# self-test
if __name__ == "__main__":