From 78e152429187ef145124b0ac0a69ffd1d52f4ed7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2010 17:12:09 +0100 Subject: Style fixes. --- apt/cache.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index b5733d98..e8688d64 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -46,12 +46,12 @@ class Cache(object): """Dictionary-like package cache. This class has all the packages that are available in it's - dictionary. + dictionary. Keyword arguments: progress -- a OpProgress object - rootdir -- a alternative root directory. if that is given - the system sources.list and system lists/ files are + rootdir -- a alternative root directory. if that is given + the system sources.list and system lists/ files are not read, only files relative to the given rootdir memonly -- build the cache in memory only """ @@ -95,12 +95,12 @@ class Cache(object): "/var/lib/apt/lists/partial", ] for d in dirs: - if not os.path.exists(rootdir+d): - print "creating: ",rootdir+d - os.makedirs(rootdir+d) + if not os.path.exists(rootdir + d): + print "creating: ", rootdir + d + os.makedirs(rootdir + d) for f in files: - if not os.path.exists(rootdir+f): - open(rootdir+f,"w") + if not os.path.exists(rootdir + f): + open(rootdir + f, "w") def _run_callbacks(self, name): """ internal helper to run a callback """ @@ -125,12 +125,12 @@ class Cache(object): self._weakref.clear() progress.op = _("Building data structures") - i=last=0 - size=len(self._cache.packages) + i = last = 0 + size = len(self._cache.packages) for pkg in self._cache.packages: if progress is not None and last+100 < i: progress.update(i/float(size)*100) - last=i + last = i # drop stuff with no versions (cruft) if len(pkg.version_list) > 0: self._set.add(pkg.name) @@ -376,9 +376,10 @@ class Cache(object): elif res == pm.RESULT_FAILED: raise SystemError("installArchives() failed") elif res == pm.RESULT_INCOMPLETE: - pass + pass else: - raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) + raise SystemError("internal-error: unknown result code " + "from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.shutdown() return (res == pm.RESULT_COMPLETED) -- cgit v1.2.3 From a8dda6d93b07b7226a3aa41baa50ca059674566e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2010 17:48:06 +0100 Subject: Some stylistic changes. --- apt/cache.py | 10 +++++++--- apt/debfile.py | 22 +++++++++++----------- apt/progress/base.py | 9 +++------ apt/progress/gtk2.py | 1 + apt/progress/old.py | 10 ++++++++++ apt/utils.py | 6 +++--- 6 files changed, 35 insertions(+), 23 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index e8688d64..2e6d24e5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -57,6 +57,10 @@ class Cache(object): """ def __init__(self, progress=None, rootdir=None, memonly=False): + self._cache = None + self._depcache = None + self._records = None + self._list = None self._callbacks = {} self._weakref = weakref.WeakValueDictionary() self._set = set() @@ -624,9 +628,9 @@ def _test(): # see if fetching works - for dir in ["/tmp/pytest", "/tmp/pytest/partial"]: - if not os.path.exists(dir): - os.mkdir(dir) + for dirname in ["/tmp/pytest", "/tmp/pytest/partial"]: + if not os.path.exists(dirname): + os.mkdir(dirname) apt_pkg.config.set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.PackageManager(cache._depcache) fetcher = apt_pkg.Acquire(apt.progress.text.AcquireProgress()) diff --git a/apt/debfile.py b/apt/debfile.py index e27917d5..ccaa25e4 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -43,6 +43,9 @@ class DebPackage(object): def __init__(self, filename=None, cache=None): self._cache = cache self._need_pkgs = [] + self._debfile = None + self.pkgname = "" + self.filename = filename self._sections = {} self._installed_conflicts = set() self._failure_string = "" @@ -168,9 +171,6 @@ class DebPackage(object): """Check the or-group for conflicts with installed pkgs.""" self._dbg(2, "_check_conflicts_or_group(): %s " % (or_group)) - or_found = False - virtual_pkg = None - for dep in or_group: depname = dep[0] ver = dep[1] @@ -287,13 +287,13 @@ class DebPackage(object): else: cachever = self._cache[pkgname].candidate.version if cachever is not None: - cmp = apt_pkg.version_compare(cachever, debver) - self._dbg(1, "CompareVersion(debver,instver): %s" % cmp) - if cmp == 0: + cmpres = apt_pkg.version_compare(cachever, debver) + self._dbg(1, "CompareVersion(debver,instver): %s" % cmpres) + if cmpres == 0: return VERSION_SAME - elif cmp < 0: + elif cmpres < 0: return VERSION_NEWER - elif cmp > 0: + elif cmpres > 0: return VERSION_OUTDATED return VERSION_NONE @@ -361,7 +361,7 @@ class DebPackage(object): for pkg in self._need_pkgs: try: self._cache[pkg].mark_install(fromUser=False) - except SystemError, e: + except SystemError: self._failure_string = _("Cannot install '%s'" % pkg) self._cache.clear() return False @@ -427,7 +427,8 @@ class DscSrcPackage(DebPackage): DebPackage.__init__(self, None, cache) self._depends = [] self._conflicts = [] - self._binaries = [] + self.pkgname = "" + self.binaries = [] if filename is not None: self.open(filename) @@ -465,7 +466,6 @@ class DscSrcPackage(DebPackage): if 'Version' in sec: self._sections['Version'] = sec['Version'] finally: - del sec del tagfile fobj.close() diff --git a/apt/progress/base.py b/apt/progress/base.py index d4342de8..6822b74a 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -16,6 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +# pylint: disable-msg = R0201 """Base classes for progress reporting. Custom progress classes should inherit from these classes. They can also be @@ -28,7 +29,6 @@ import re import select import apt_pkg -from apt.deprecation import function_deprecated_by __all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress'] @@ -137,7 +137,7 @@ class CdromProgress(object): class InstallProgress(object): """Class to report the progress of installing packages.""" - percent, select_timeout, status = 0.0, 0.1, "" + child_pid, percent, select_timeout, status = 0, 0.0, 0.1, "" def __init__(self): (self.statusfd, self.writefd) = os.pipe() @@ -159,9 +159,6 @@ class InstallProgress(object): def status_change(self, pkg, percent, status): """(Abstract) Called when the APT status changed.""" - # compat with 0.7 - if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"): - self.statusChange(pkg, percent, status) def dpkg_status_change(self, pkg, status): """(Abstract) Called when the dpkg status changed.""" @@ -269,7 +266,7 @@ class InstallProgress(object): try: select.select([self.status_stream], [], [], self.select_timeout) - except select.error, (errno_, errstr): + except select.error, (errno_, _errstr): if errno_ != errno.EINTR: raise diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index 29e730a3..acb01eed 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -124,6 +124,7 @@ class GInstallProgress(gobject.GObject, base.InstallProgress): base.InstallProgress.__init__(self) gobject.GObject.__init__(self) self.finished = False + self.apt_status = -1 self.time_last_update = time.time() self.term = term reaper = vte.reaper_get() diff --git a/apt/progress/old.py b/apt/progress/old.py index b2f6f0d5..c64eee57 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -18,6 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +# pylint: disable-msg = C0103 """Deprecated progress reporting classes. This module provides classes for compatibility with python-apt 0.7. They are @@ -195,10 +196,19 @@ class InstallProgress(DumbInstallProgress, base.InstallProgress): base.InstallProgress.update_interface) waitChild = function_deprecated_by(base.InstallProgress.wait_child) + def status_change(self, pkg, percent, status): + """(Abstract) Called when the APT status changed.""" + # compat with 0.7 + if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"): + self.statusChange(pkg, percent, status) + class DpkgInstallProgress(InstallProgress): """Progress handler for a local Debian package installation.""" + debfile = "" + debname = "" + def run(self, debfile): """Start installing the given Debian package.""" # Deprecated stuff diff --git a/apt/utils.py b/apt/utils.py index dd52f824..80ba6d65 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -61,7 +61,7 @@ def get_release_filename_for_pkg(cache, pkgname, label, release): for aver in pkg._pkg.version_list: if aver is None or aver.file_list is None: continue - for ver_file, index in aver.file_list: + for ver_file, _index in aver.file_list: #print verFile if (ver_file.origin == label and ver_file.label == label and @@ -75,8 +75,8 @@ def get_release_filename_for_pkg(cache, pkgname, label, release): if (indexfile and indexfile.describe == m.describe and indexfile.is_trusted): - dir = apt_pkg.config.find_dir("Dir::State::lists") + dirname = apt_pkg.config.find_dir("Dir::State::lists") name = (apt_pkg.uri_to_filename(metaindex.uri) + "dists_%s_Release" % metaindex.dist) - return dir+name + return dirname + name return None -- cgit v1.2.3