diff options
| author | Julian Andres Klode <jak@debian.org> | 2014-01-06 13:24:51 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2014-01-06 13:24:51 +0100 |
| commit | 8b8a55f10ca47fe297fbb9b16a8e100658c60df3 (patch) | |
| tree | d2e941190673478d7d92821715ac8df476e17843 /apt | |
| parent | f6c94dbe9cbfa645b19832842183e248f940f829 (diff) | |
| download | python-apt-8b8a55f10ca47fe297fbb9b16a8e100658c60df3.tar.gz | |
Use print_function everywhere
This brings the code closer to Python 3. Automatically converted
using 2to3 -f print.
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/__init__.py | 2 | ||||
| -rw-r--r-- | apt/auth.py | 2 | ||||
| -rw-r--r-- | apt/cache.py | 28 | ||||
| -rw-r--r-- | apt/cdrom.py | 2 | ||||
| -rw-r--r-- | apt/debfile.py | 28 | ||||
| -rw-r--r-- | apt/package.py | 70 | ||||
| -rw-r--r-- | apt/progress/__init__.py | 2 | ||||
| -rw-r--r-- | apt/progress/base.py | 4 | ||||
| -rw-r--r-- | apt/progress/gtk2.py | 4 | ||||
| -rw-r--r-- | apt/progress/text.py | 2 | ||||
| -rw-r--r-- | apt/utils.py | 1 |
11 files changed, 83 insertions, 62 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index c4e78ba0..b8d291e3 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -18,6 +18,8 @@ # USA # import the core of apt_pkg """High-Level Interface for working with apt.""" +from __future__ import print_function + import apt_pkg # import some fancy classes diff --git a/apt/auth.py b/apt/auth.py index acc612a9..814cf1dc 100644 --- a/apt/auth.py +++ b/apt/auth.py @@ -24,6 +24,8 @@ # USA """Handle GnuPG keys used to trust signed repositories.""" +from __future__ import print_function + import os import os.path import shutil diff --git a/apt/cache.py b/apt/cache.py index 6b1e2bda..593e70a7 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -19,6 +19,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +from __future__ import print_function + import fnmatch import os import weakref @@ -721,31 +723,31 @@ class FilteredCache(object): def cache_pre_changed(): - print "cache pre changed" + print("cache pre changed") def cache_post_changed(): - print "cache post changed" + print("cache post changed") def _test(): """Internal test code.""" - print "Cache self test" + print("Cache self test") apt_pkg.init() cache = Cache(apt.progress.text.OpProgress()) cache.connect("cache_pre_change", cache_pre_changed) cache.connect("cache_post_change", cache_post_changed) - print ("aptitude" in cache) + print(("aptitude" in cache)) pkg = cache["aptitude"] - print pkg.name - print len(cache) + print(pkg.name) + print(len(cache)) for pkgname in cache.keys(): assert cache[pkgname].name == pkgname cache.upgrade() changes = cache.get_changes() - print len(changes) + print(len(changes)) for pkg in changes: assert pkg.name @@ -759,28 +761,28 @@ def _test(): cache._fetch_archives(fetcher, pm) #sys.exit(1) - print "Testing filtered cache (argument is old cache)" + print("Testing filtered cache (argument is old cache)") filtered = FilteredCache(cache) filtered.cache.connect("cache_pre_change", cache_pre_changed) filtered.cache.connect("cache_post_change", cache_post_changed) filtered.cache.upgrade() filtered.set_filter(MarkedChangesFilter()) - print len(filtered) + print(len(filtered)) for pkgname in filtered.keys(): assert pkgname == filtered[pkg].name - print len(filtered) + print(len(filtered)) - print "Testing filtered cache (no argument)" + print("Testing filtered cache (no argument)") filtered = FilteredCache(progress=apt.progress.base.OpProgress()) filtered.cache.connect("cache_pre_change", cache_pre_changed) filtered.cache.connect("cache_post_change", cache_post_changed) filtered.cache.upgrade() filtered.set_filter(MarkedChangesFilter()) - print len(filtered) + print(len(filtered)) for pkgname in filtered.keys(): assert pkgname == filtered[pkgname].name - print len(filtered) + print(len(filtered)) if __name__ == '__main__': _test() diff --git a/apt/cdrom.py b/apt/cdrom.py index 3c48fd07..35a0b180 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -20,6 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Classes related to cdrom handling.""" +from __future__ import print_function + import glob import apt_pkg diff --git a/apt/debfile.py b/apt/debfile.py index 679c8468..1dd1a372 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -17,6 +17,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Classes for working with locally available Debian packages.""" +from __future__ import print_function + import apt import apt_inst import apt_pkg @@ -659,7 +661,7 @@ class DebPackage(object): def _dbg(self, level, msg): """Write debugging output to sys.stderr.""" if level <= self.debug: - print >> sys.stderr, msg + print(msg, file=sys.stderr) def install(self, install_progress=None): """Install the package.""" @@ -756,25 +758,25 @@ def _test(): cache = Cache() vp = "www-browser" - print "%s virtual: %s" % (vp, cache.is_virtual_package(vp)) + print("%s virtual: %s" % (vp, cache.is_virtual_package(vp))) providers = cache.get_providing_packages(vp) - print "Providers for %s :" % vp + print("Providers for %s :" % vp) for pkg in providers: - print " %s" % pkg.name + print(" %s" % pkg.name) d = DebPackage(sys.argv[1], cache) - print "Deb: %s" % d.pkgname + print("Deb: %s" % d.pkgname) if not d.check(): - print "can't be satified" - print d._failure_string - print "missing deps: %s" % d.missing_deps - print d.required_changes + print("can't be satified") + print(d._failure_string) + print("missing deps: %s" % d.missing_deps) + print(d.required_changes) - print d.filelist + print(d.filelist) - print "Installing ..." + print("Installing ...") ret = d.install(InstallProgress()) - print ret + print(ret) #s = DscSrcPackage(cache, "../tests/3ddesktop_0.2.9-6.dsc") #s.check_dep() @@ -783,7 +785,7 @@ def _test(): s = DscSrcPackage(cache=cache) d = "libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)" - print s._satisfy_depends(apt_pkg.parse_depends(d, False)) + print(s._satisfy_depends(apt_pkg.parse_depends(d, False))) if __name__ == "__main__": _test() diff --git a/apt/package.py b/apt/package.py index d4217195..f7f07680 100644 --- a/apt/package.py +++ b/apt/package.py @@ -19,6 +19,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Functionality related to packages.""" +from __future__ import print_function + import httplib import os import sys @@ -534,7 +536,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, @@ -583,7 +585,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)) @@ -1134,59 +1136,59 @@ class Package(object): 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__": diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 776a7034..c689de5c 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -23,5 +23,7 @@ This package provides progress reporting for the python-apt package. The module GTK+ applications, and the module 'text' provides classes for terminals, etc. """ +from __future__ import print_function + __all__ = [] diff --git a/apt/progress/base.py b/apt/progress/base.py index 2c80ae29..66d56173 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -22,6 +22,8 @@ Custom progress classes should inherit from these classes. They can also be used as dummy progress classes which simply do nothing. """ +from __future__ import print_function + import errno import fcntl import os @@ -217,7 +219,7 @@ class InstallProgress(object): except IOError as err: # resource temporarly unavailable is ignored if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK: - print err.strerror + print(err.strerror) return pkgname = status = status_str = percent = base = "" diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index b978c34f..7d142399 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -22,6 +22,8 @@ # USA """GObject-powered progress classes and a GTK+ status widget.""" +from __future__ import print_function + import pygtk pygtk.require('2.0') import gtk @@ -422,7 +424,7 @@ def _test(): try: cache.commit(apt_progress.acquire, apt_progress.install) except Exception as exc: - print >> sys.stderr, "Exception happened:", exc + print("Exception happened:", exc, file=sys.stderr) if len(sys.argv) > 1: deb = DebPackage(sys.argv[1], cache) deb.install(apt_progress.dpkg_install) diff --git a/apt/progress/text.py b/apt/progress/text.py index 76a4309e..880a112c 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -15,6 +15,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Progress reporting for text interfaces.""" +from __future__ import print_function + import os import sys diff --git a/apt/utils.py b/apt/utils.py index 9451f4bc..5a914fc2 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +from __future__ import print_function import os.path |
