diff options
| -rw-r--r-- | apt/cache.py | 10 | ||||
| -rw-r--r-- | aptsources/distinfo.py | 6 | ||||
| -rw-r--r-- | aptsources/distro.py | 12 | ||||
| -rw-r--r-- | aptsources/sourceslist.py | 4 | ||||
| -rw-r--r-- | debian/changelog | 3 | ||||
| -rw-r--r-- | doc/examples/all_deps.py | 4 | ||||
| -rwxr-xr-x | doc/examples/configisc.py | 2 | ||||
| -rwxr-xr-x | doc/examples/records.py | 2 | ||||
| -rwxr-xr-x | utils/get_ubuntu_mirrors_from_lp.py | 2 |
9 files changed, 23 insertions, 22 deletions
diff --git a/apt/cache.py b/apt/cache.py index 303bb99f..f134ab0a 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -105,10 +105,10 @@ class Cache(object): raise StopIteration def has_key(self, key): - return key in self._dict + return (key in self._dict) def __contains__(self, key): - return key in self._dict + return (key in self._dict) def __len__(self): return len(self._dict) @@ -350,10 +350,10 @@ class FilteredCache(object): return self._filtered.keys() def has_key(self, key): - return key in self._filtered + return (key in self._filtered) def __contains__(self, key): - return key in self._filtered + return (key in self._filtered) def _reapplyFilter(self): " internal helper to refilter " @@ -401,7 +401,7 @@ if __name__ == "__main__": c = Cache(apt.progress.OpTextProgress()) c.connect("cache_pre_change", cache_pre_changed) c.connect("cache_post_change", cache_post_changed) - print "aptitude" in c + print ("aptitude" in c) p = c["aptitude"] print p.name print len(c) diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index d23c79c5..3c499b52 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -62,7 +62,7 @@ class Template: def is_mirror(self, url): ''' Check if a given url of a repository is a valid mirror ''' proto, hostname, dir = split_url(url) - if self.mirror_set.has_key(hostname): + if hostname in self.mirror_set: return self.mirror_set[hostname].has_repository(proto, dir) else: return False @@ -217,7 +217,7 @@ class DistInfo: template.match_uri = value elif (field == 'MirrorsFile' or field == 'MirrorsFile-%s' % self.arch): - if not map_mirror_sets.has_key(value): + if value not in map_mirror_sets: mirror_set = {} try: mirror_data = filter(match_mirror_line.match, @@ -230,7 +230,7 @@ class DistInfo: location = match_loc.sub(r"\1", line) continue (proto, hostname, dir) = split_url(line) - if mirror_set.has_key(hostname): + if hostname in mirror_set: mirror_set[hostname].add_repository(proto, dir) else: mirror_set[hostname] = Mirror( diff --git a/aptsources/distro.py b/aptsources/distro.py index 4d6b7acf..a8f1d0fd 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -187,7 +187,7 @@ class Distribution: if mirror_template: self.nearest_server = mirror_template % country_code - if self.countries.has_key(country_code): + if country_code in self.countries: self.country = self.countries[country_code] self.country_code = country_code @@ -199,7 +199,7 @@ class Distribution: l = server.find(".archive.ubuntu.com") if i != -1 and l != -1: country = server[i+len("://"):l] - if self.countries.has_key(country): + if country in self.countries: # TRANSLATORS: %s is a country return _("Server for %s") % \ gettext.dgettext("iso_3166", @@ -292,7 +292,7 @@ class Distribution: """ # if we don't that distro, just reutnr (can happen for e.g. # dapper-update only in deb-src - if not comps_per_dist.has_key(source.dist): + if source.dist not in comps_per_dist: return # if we have seen this component already for this distro, # return (nothing to do @@ -311,12 +311,12 @@ class Distribution: comps_per_sdist = {} for s in sources: if s.type == self.binary_type: - if not comps_per_dist.has_key(s.dist): + if s.dist not in comps_per_dist: comps_per_dist[s.dist] = set() map(comps_per_dist[s.dist].add, s.comps) for s in self.source_code_sources: if s.type == self.source_type: - if not comps_per_sdist.has_key(s.dist): + if s.dist not in comps_per_sdist: comps_per_sdist[s.dist] = set() map(comps_per_sdist[s.dist].add, s.comps) @@ -412,7 +412,7 @@ class DebianDistribution(Distribution): l = server.find(".debian.org") if i != -1 and l != -1: country = server[i+len("://ftp."):l] - if self.countries.has_key(country): + if country in self.countries: # TRANSLATORS: %s is a country return _("Server for %s") % gettext.dgettext( "iso_3166", self.countries[country].rstrip()).rstrip() diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index be17cd1f..a0346267 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -368,7 +368,7 @@ class SourcesList: open(path, "w").write(header) return for source in self.list: - if not files.has_key(source.file): + if source.file not in files: files[source.file] = open(source.file, "w") files[source.file].write(source.str()) for f in files: @@ -386,7 +386,7 @@ class SourcesList: # source entries if source.template.child == True: key = source.template - if not used_child_templates.has_key(key): + if key not in used_child_templates: used_child_templates[key] = [] temp = used_child_templates[key] temp.append(source) diff --git a/debian/changelog b/debian/changelog index a44550d5..d920c16e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,8 +28,9 @@ python-apt (0.7.9~exp2) experimental; urgency=low * aptsources/distinfo.py: - Allow @ in mirror urls (Closes: #478171) (LP: #223097) * Merge Ben Finney's whitespace changes (Closes: #481563) + * Merge Ben Finney's do not use has_key() (Closes: #481878) - -- Julian Andres Klode <jak@debian.org> Sun, 11 Jan 2009 19:25:55 +0100 + -- Julian Andres Klode <jak@debian.org> Sun, 11 Jan 2009 19:46:12 +0100 python-apt (0.7.9~exp1) experimental; urgency=low diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py index e8c9eaaf..0a2f3157 100644 --- a/doc/examples/all_deps.py +++ b/doc/examples/all_deps.py @@ -10,10 +10,10 @@ def dependencies(cache, pkg, deps, key="Depends"): if candver == None: return deps dependslist = candver.DependsList - if dependslist.has_key(key): + if key in dependslist: for depVerList in dependslist[key]: for dep in depVerList: - if cache.has_key(dep.TargetPkg.Name): + if dep.TargetPkg.Name in cache: if pkg.name != dep.TargetPkg.Name and \ not dep.TargetPkg.Name in deps: deps.add(dep.TargetPkg.Name) diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py index 1d5965f5..de8ec6be 100755 --- a/doc/examples/configisc.py +++ b/doc/examples/configisc.py @@ -27,7 +27,7 @@ apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0]) # print "%s \"%s\";" % (I, Cnf[I]) # bind8 config file.. -if Cnf.has_key("Zone"): +if Cnf.Exists("Zone"): print "Zones: ", Cnf.SubTree("zone").List() for I in Cnf.List("zone"): SubCnf = Cnf.SubTree(I) diff --git a/doc/examples/records.py b/doc/examples/records.py index a7a87727..a0fc8dc4 100755 --- a/doc/examples/records.py +++ b/doc/examples/records.py @@ -7,7 +7,7 @@ cache = apt.Cache() for pkg in cache: if not pkg.candidateRecord: continue - if pkg.candidateRecord.has_key("Task"): + if "Task" in pkg.candidateRecord: print "Pkg %s is part of '%s'" % ( pkg.name, pkg.candidateRecord["Task"].split()) #print pkg.candidateRecord diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index 59ddd84e..b912f28d 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -70,7 +70,7 @@ def find(split): country = re.search(r"<strong>(.+?)</strong>", split) if not country: return - if countries.has_key(country.group(1)): + if country.group(1) in countries: lines.append("#LOC:%s" % countries[country.group(1)].upper()) else: lines.append("#LOC:%s" % country.group(1)) |
