From 3bf9c3fe4d19ed4d985dc8b7747a737699f46a7e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Dec 2013 23:25:13 +0100 Subject: make test_pep8.py pass --- apt/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt/utils.py') diff --git a/apt/utils.py b/apt/utils.py index 08140258..9451f4bc 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -32,7 +32,7 @@ def get_maintenance_end_date(release_date, m_months): years = m_months // 12 months = m_months % 12 support_end_year = (release_date.year + years + - (release_date.month + months)//12) + (release_date.month + months) // 12) support_end_month = (release_date.month + months) % 12 # special case: this happens when e.g. doing 2010-06 + 18 months if support_end_month == 0: -- cgit v1.2.3 From 8b8a55f10ca47fe297fbb9b16a8e100658c60df3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 6 Jan 2014 13:24:51 +0100 Subject: Use print_function everywhere This brings the code closer to Python 3. Automatically converted using 2to3 -f print. --- apt/__init__.py | 2 ++ apt/auth.py | 2 ++ apt/cache.py | 28 ++++++++++--------- apt/cdrom.py | 2 ++ apt/debfile.py | 28 ++++++++++--------- apt/package.py | 70 ++++++++++++++++++++++++----------------------- apt/progress/__init__.py | 2 ++ apt/progress/base.py | 4 ++- apt/progress/gtk2.py | 4 ++- apt/progress/text.py | 2 ++ apt/utils.py | 1 + aptsources/__init__.py | 2 ++ aptsources/sourceslist.py | 2 +- 13 files changed, 86 insertions(+), 63 deletions(-) (limited to 'apt/utils.py') 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 diff --git a/aptsources/__init__.py b/aptsources/__init__.py index 0929e12b..d711b4f3 100644 --- a/aptsources/__init__.py +++ b/aptsources/__init__.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import apt_pkg diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 1b68d52e..91ce8eff 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -from __future__ import absolute_import +from __future__ import absolute_import, print_function import glob import logging -- cgit v1.2.3 From 9db885ce4fb06f8e154b97cd6cf4e0f09a241f54 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 30 Jun 2014 11:21:36 +0200 Subject: make pep8 happy (again) --- apt/cache.py | 2 +- apt/debfile.py | 20 +++++++++--------- apt/utils.py | 10 ++++----- aptsources/distinfo.py | 4 ++-- aptsources/distro.py | 42 ++++++++++++++++++------------------- aptsources/sourceslist.py | 41 ++++++++++++++++++------------------ doc/examples/all_deps.py | 4 ++-- doc/source/examples/missing-deps.py | 2 +- tests/test_aptsources.py | 38 ++++++++++++++++----------------- tests/test_debfile_multiarch.py | 2 +- tests/test_pep8.py | 3 ++- utils/get_debian_mirrors.py | 2 +- utils/get_ubuntu_mirrors_from_lp.py | 2 +- 13 files changed, 86 insertions(+), 86 deletions(-) (limited to 'apt/utils.py') diff --git a/apt/cache.py b/apt/cache.py index 36a9fa6b..69ee3693 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -530,7 +530,7 @@ class Cache(object): def connect(self, name, callback): """ connect to a signal, currently only used for cache_{post,pre}_{changed,open} """ - if not name in self._callbacks: + if name not in self._callbacks: self._callbacks[name] = [] self._callbacks[name].append(callback) diff --git a/apt/debfile.py b/apt/debfile.py index ca38fdc0..2c95bdf1 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -119,7 +119,7 @@ class DebPackage(object): # now do the real multiarch checking multiarch_pkgname = "%s:%s" % (pkgname, self._multiarch) # the upper layers will handle this - if not multiarch_pkgname in self._cache: + if multiarch_pkgname not in self._cache: return multiarch_pkgname # now check the multiarch state cand = self._cache[multiarch_pkgname].candidate._cand @@ -131,7 +131,7 @@ class DebPackage(object): # for conflicts we need a special case here, any not multiarch enabled # package has a implicit conflict if (in_conflict_checking and - not (cand.multi_arch & cand.MULTI_ARCH_SAME)): + not (cand.multi_arch & cand.MULTI_ARCH_SAME)): return pkgname return multiarch_pkgname @@ -152,7 +152,7 @@ class DebPackage(object): depname = self._maybe_append_multiarch_suffix(depname) # check for virtual pkgs - if not depname in self._cache: + if depname not in self._cache: if self._cache.is_virtual_package(depname): self._dbg( 3, "_is_or_group_satisfied(): %s is virtual dep" % @@ -190,7 +190,7 @@ class DebPackage(object): depname = self._maybe_append_multiarch_suffix(depname) # if we don't have it in the cache, it may be virtual - if not depname in self._cache: + if depname not in self._cache: if not self._cache.is_virtual_package(depname): continue providers = self._cache.get_providing_packages(depname) @@ -245,7 +245,7 @@ class DebPackage(object): #print "pkgver: %s " % pkgver #print "oper: %s " % oper if (apt_pkg.check_dep(pkgver, oper, ver) and not - self.replaces_real_pkg(pkgname, oper, ver)): + self.replaces_real_pkg(pkgname, oper, ver)): self._failure_string += _("Conflicts with the installed package " "'%s'") % pkg.name self._dbg(3, "conflicts with installed pkg '%s'" % pkg.name) @@ -266,7 +266,7 @@ class DebPackage(object): depname, in_conflict_checking=True) # check conflicts with virtual pkgs - if not depname in self._cache: + if depname not in self._cache: # FIXME: we have to check for virtual replaces here as # well (to pass tests/gdebi-test8.deb) if self._cache.is_virtual_package(depname): @@ -430,7 +430,7 @@ class DebPackage(object): self._cache.op_progress.done() return False if (c_or.target_pkg.name in provides and - self.pkgname != pkg.name): + self.pkgname != pkg.name): self._dbg( 2, "would break (conflicts) %s" % provides) self._failure_string += _( @@ -483,7 +483,7 @@ class DebPackage(object): self._check_was_run = True # check arch - if not "Architecture" in self._sections: + if "Architecture" not in self._sections: self._dbg(1, "ERROR: no architecture field") self._failure_string = _("No Architecture field in the package") return False @@ -713,11 +713,11 @@ class DscSrcPackage(DebPackage): try: for sec in tagfile: for tag in depends_tags: - if not tag in sec: + if tag not in sec: continue self._depends.extend(apt_pkg.parse_src_depends(sec[tag])) for tag in conflicts_tags: - if not tag in sec: + if tag not in sec: continue self._conflicts.extend(apt_pkg.parse_src_depends(sec[tag])) if 'Source' in sec: diff --git a/apt/utils.py b/apt/utils.py index 5a914fc2..948aac92 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -50,7 +50,7 @@ def get_release_date_from_release_file(path): return None tag = apt_pkg.TagFile(open(path)) section = next(tag) - if not "Date" in section: + if "Date" not in section: return None date = section["Date"] return apt_pkg.str_to_time(date) @@ -70,8 +70,8 @@ def get_release_filename_for_pkg(cache, pkgname, label, release): for ver_file, _index in aver.file_list: #print verFile if (ver_file.origin == label and - ver_file.label == label and - ver_file.archive == release): + ver_file.label == label and + ver_file.archive == release): ver = aver if not ver: return None @@ -79,8 +79,8 @@ def get_release_filename_for_pkg(cache, pkgname, label, release): for metaindex in cache._list.list: for m in metaindex.index_files: if (indexfile and - indexfile.describe == m.describe and - indexfile.is_trusted): + indexfile.describe == m.describe and + indexfile.is_trusted): dirname = apt_pkg.config.find_dir("Dir::State::lists") name = (apt_pkg.uri_to_filename(metaindex.uri) + "dists_%s_Release" % metaindex.dist) diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index b03e68f8..8fcbac96 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -254,8 +254,8 @@ class DistInfo(object): template.description = _(value) elif field == 'Component': if (component and not - template.has_component(component.name)): - template.components.append(component) + template.has_component(component.name)): + template.components.append(component) component = Component(value) elif field == 'CompDescription': component.set_description(_(value)) diff --git a/aptsources/distro.py b/aptsources/distro.py index 9b48a10f..f75aa06b 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -77,7 +77,7 @@ class Distribution(object): # find the distro template for template in self.sourceslist.matcher.templates: if (self.is_codename(template.name) and - template.distribution == self.id): + template.distribution == self.id): #print "yeah! found a template for %s" % self.description #print template.description, template.base_uri, \ # template.components @@ -96,40 +96,40 @@ class Distribution(object): #source_code = [] for source in self.sourceslist.list: if (not source.invalid and - self.is_codename(source.dist) and - source.template and - source.template.official and - self.is_codename(source.template.name)): + self.is_codename(source.dist) and + source.template and + source.template.official and + self.is_codename(source.template.name)): #print "yeah! found a distro repo: %s" % source.line # cdroms need do be handled differently if (source.uri.startswith("cdrom:") and - not source.disabled): - self.cdrom_sources.append(source) - cdrom_comps.extend(source.comps) + not source.disabled): + self.cdrom_sources.append(source) + cdrom_comps.extend(source.comps) elif (source.uri.startswith("cdrom:") and - source.disabled): + source.disabled): self.cdrom_sources.append(source) elif (source.type == self.binary_type and - not source.disabled): + not source.disabled): self.main_sources.append(source) comps.extend(source.comps) media.append(source.uri) elif (source.type == self.binary_type and - source.disabled): + source.disabled): self.disabled_sources.append(source) - elif (source.type == self.source_type - and not source.disabled): + elif (source.type == self.source_type and + not source.disabled): self.source_code_sources.append(source) elif (source.type == self.source_type and - source.disabled): + source.disabled): self.disabled_sources.append(source) if (not source.invalid and - source.template in self.source_template.children): + source.template in self.source_template.children): if (not source.disabled - and source.type == self.binary_type): - self.child_sources.append(source) + and source.type == self.binary_type): + self.child_sources.append(source) elif (not source.disabled - and source.type == self.source_type): + and source.type == self.source_type): self.source_code_sources.append(source) else: self.disabled_sources.append(source) @@ -256,9 +256,9 @@ class Distribution(object): for server in self.used_servers: mirror_entry = [self._get_mirror_name(server), server, False] if (compare_mirrors(server, self.nearest_server) or - compare_mirrors(server, self.main_server)): + compare_mirrors(server, self.main_server)): continue - elif not mirror_entry in mirrors: + elif mirror_entry not in mirrors: mirrors.append(mirror_entry) return mirrors @@ -405,7 +405,7 @@ class Distribution(object): for source in self.child_sources: # Do not change the forces server of a child source if (source.template.base_uri is None or - source.template.base_uri != source.uri): + source.template.base_uri != source.uri): change_server_of_source(source, uri, seen_binary) for source in self.source_code_sources: change_server_of_source(source, uri, seen_source) diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 91ce8eff..842b1451 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -87,23 +87,22 @@ class SourceEntry(object): """ single sources.list entry """ def __init__(self, line, file=None): - self.invalid = False # is the source entry valid - self.disabled = False # is it disabled ('#' in front) - self.type = "" # what type (deb, deb-src) - self.architectures = [] # architectures - self.trusted = None # Trusted - self.uri = "" # base-uri - self.dist = "" # distribution (dapper, edgy, etc) - self.comps = [] # list of available componetns - # (may empty) - self.comment = "" # (optional) comment - self.line = line # the original sources.list line + self.invalid = False # is the source entry valid + self.disabled = False # is it disabled ('#' in front) + self.type = "" # what type (deb, deb-src) + self.architectures = [] # architectures + self.trusted = None # Trusted + self.uri = "" # base-uri + self.dist = "" # distribution (dapper, edgy, etc) + self.comps = [] # list of available componetns (may empty) + self.comment = "" # (optional) comment + self.line = line # the original sources.list line if file is None: file = apt_pkg.config.find_dir( "Dir::Etc") + apt_pkg.config.find("Dir::Etc::sourcelist") - self.file = file # the file that the entry is located in + self.file = file # the file that the entry is located in self.parse(line) - self.template = None # type DistInfo.Suite + self.template = None # type DistInfo.Suite self.children = [] def __eq__(self, other): @@ -301,7 +300,7 @@ class SourcesList(object): def __find(self, *predicates, **attrs): for source in self.list: if (all(getattr(source, key) == attrs[key] for key in attrs) and - all(predicate(source) for predicate in predicates)): + all(predicate(source) for predicate in predicates)): yield source def add(self, type, uri, dist, orig_comps, comment="", pos=-1, file=None, @@ -379,8 +378,8 @@ class SourcesList(object): if backup_ext is None: backup_ext = time.strftime("%y%m%d.%H%M") for source in self.list: - if not source.file in already_backuped \ - and os.path.exists(source.file): + if (source.file not in already_backuped + and os.path.exists(source.file)): shutil.copy(source.file, "%s%s" % (source.file, backup_ext)) return backup_ext @@ -467,15 +466,15 @@ class SourceEntryMatcher(object): found = False for template in self.templates: if (re.search(template.match_uri, source.uri) and - re.match(template.match_name, source.dist) and - # deb is a valid fallback for deb-src (if that is not - # definied, see #760035 - (source.type == template.type or template.type == "deb")): + re.match(template.match_name, source.dist) and + # deb is a valid fallback for deb-src (if that is not + # definied, see #760035 + (source.type == template.type or template.type == "deb")): found = True source.template = template break elif (template.is_mirror(source.uri) and - re.match(template.match_name, source.dist)): + re.match(template.match_name, source.dist)): found = True source.template = template break diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py index 179501f4..6ce264bb 100644 --- a/doc/examples/all_deps.py +++ b/doc/examples/all_deps.py @@ -14,8 +14,8 @@ def dependencies(cache, pkg, deps, key="Depends"): for depVerList in dependslist[key]: for dep in depVerList: if dep.target_pkg.name in cache: - if pkg.name != dep.target_pkg.name and \ - not dep.target_pkg.name in deps: + if (pkg.name != dep.target_pkg.name and + dep.target_pkg.name not in deps): deps.add(dep.target_pkg.name) dependencies( cache, cache[dep.target_pkg.name], deps, key) diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py index 7af18128..b9ccdc19 100644 --- a/doc/source/examples/missing-deps.py +++ b/doc/source/examples/missing-deps.py @@ -43,7 +43,7 @@ def main(): # Check every version for pfile, _ in version.file_list: if (pfile.origin == "Debian" and pfile.component == "main" and - pfile.archive == "unstable"): + pfile.archive == "unstable"): # We only want packages from Debian unstable main. check_version(version) break diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index f955205f..f174bd41 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -77,9 +77,9 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy" and - "multiverse" in entry.comps): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy" and + "multiverse" in entry.comps): found = True self.assertTrue(found) @@ -90,10 +90,10 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "natty" and - entry.architectures == [] and - "multiverse" in entry.comps): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "natty" and + entry.architectures == [] and + "multiverse" in entry.comps): found = True self.assertTrue(found) @@ -104,10 +104,10 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "natty" and - set(entry.architectures) == set(["amd64", "i386"]) and - set(entry.comps) == set(["main", "universe"])): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "natty" and + set(entry.architectures) == set(["amd64", "i386"]) and + set(entry.comps) == set(["main", "universe"])): found = True self.assertTrue(found) # test to add something new: multiverse *and* @@ -120,8 +120,8 @@ class TestAptSources(unittest.TestCase): found_something = 0 for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy"): for c in entry.comps: if c == "universe": found_universe += 1 @@ -219,11 +219,11 @@ class TestAptSources(unittest.TestCase): found = {} for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - "edgy" in entry.dist): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + "edgy" in entry.dist): for c in entry.comps: if c == comp: - if not entry.dist in found: + if entry.dist not in found: found[entry.dist] = 0 found[entry.dist] += 1 #print "".join([s.str() for s in sources]) @@ -236,11 +236,11 @@ class TestAptSources(unittest.TestCase): found = {} for entry in sources: if (entry.type == "deb" and - entry.template and - entry.template.name == "edgy"): + entry.template and + entry.template.name == "edgy"): for c in entry.comps: if c == comp: - if not entry.dist in found.has_key: + if entry.dist not in found.has_key: found[entry.dist] = 0 found[entry.dist] += 1 #print "".join([s.str() for s in sources]) diff --git a/tests/test_debfile_multiarch.py b/tests/test_debfile_multiarch.py index 045daf72..f8847838 100644 --- a/tests/test_debfile_multiarch.py +++ b/tests/test_debfile_multiarch.py @@ -39,7 +39,7 @@ class TestDebfileMultiarch(unittest.TestCase): # WARNING: this assumes that lib3ds-1-3 is a non-multiarch lib # use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work canary = "lib3ds-1-3" - if not canary in cache: + if canary not in cache: # TODO: use unittest.skip #logging.warning("skipping test because %s is missing" % canary) return diff --git a/tests/test_pep8.py b/tests/test_pep8.py index 2e1f43fc..b3ec2dba 100755 --- a/tests/test_pep8.py +++ b/tests/test_pep8.py @@ -16,7 +16,8 @@ class PackagePep8TestCase(unittest.TestCase): # E126 continuation line over-indented for hanging indent # E127 continuation line over-indented for visual indent # E128 continuation line under-indented for visual indent - "--ignore=E125,E126,E127,E128", + # E265 block comment should start with '# ' + "--ignore=E125,E126,E127,E128,E265", "--exclude", "build,tests/old", "--repeat", py_dir]) if res != 0: diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py index 5f4d7ff0..de4ebb95 100755 --- a/utils/get_debian_mirrors.py +++ b/utils/get_debian_mirrors.py @@ -29,7 +29,7 @@ masterlist = urllib2.urlopen("http://anonscm.debian.org/viewvc/" "mirror/Mirrors.masterlist?revision=HEAD") for mirror in deb822.Deb822.iter_paragraphs(masterlist): - if not "Country" in mirror: + if "Country" not in mirror: continue country = mirror["Country"].split(None, 1)[0] site = mirror["Site"] diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index dd02b63d..41d37be9 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -34,7 +34,7 @@ countries = {} for entry in d.entries: countrycode = entry.mirror_countrycode - if not countrycode in countries: + if countrycode not in countries: countries[countrycode] = set() for link in entry.links: countries[countrycode].add(link.href) -- cgit v1.2.3