From abc9feb18b268cbc4ddb79aabb30ce352e31b44a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 21 Oct 2013 14:35:33 +0200 Subject: doc/examples: Start updating to new API --- doc/examples/all_deps.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'doc/examples/all_deps.py') diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py index 992e98d8..179501f4 100644 --- a/doc/examples/all_deps.py +++ b/doc/examples/all_deps.py @@ -6,19 +6,19 @@ import apt def dependencies(cache, pkg, deps, key="Depends"): #print "pkg: %s (%s)" % (pkg.name, deps) - candver = cache._depcache.GetCandidateVer(pkg._pkg) + candver = cache._depcache.get_candidate_ver(pkg._pkg) if candver is None: return deps - dependslist = candver.DependsList + dependslist = candver.depends_list if key in dependslist: for depVerList in dependslist[key]: for dep in depVerList: - if dep.TargetPkg.Name in cache: - if pkg.name != dep.TargetPkg.Name and \ - not dep.TargetPkg.Name in deps: - deps.add(dep.TargetPkg.Name) + if dep.target_pkg.name in cache: + if pkg.name != dep.target_pkg.name and \ + not dep.target_pkg.name in deps: + deps.add(dep.target_pkg.name) dependencies( - cache, cache[dep.TargetPkg.Name], deps, key) + cache, cache[dep.target_pkg.name], deps, key) return deps -- 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 'doc/examples/all_deps.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