diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-01-11 19:53:01 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-01-11 19:53:01 +0100 |
| commit | c94a512af6836c4d8f3835a5a6b3719ad7245249 (patch) | |
| tree | b7e26af9a794cdc8a81fcbd42aa34c36ad645e92 /aptsources | |
| parent | b237760c6d7009f9833b86e6dbfc3cbf6d059977 (diff) | |
| parent | 75676866d4bf394b3ba1ddef06e0c93f6da03242 (diff) | |
| download | python-apt-c94a512af6836c4d8f3835a5a6b3719ad7245249.tar.gz | |
* Merge Ben Finney's do not use has_key() (Closes: #481878)
A little bit adjusted to not remove the has_key() methods,
and to use has_key() where needed [the low-level part does
not have the needed functionality for 'key in mapping'].
Diffstat (limited to 'aptsources')
| -rw-r--r-- | aptsources/distinfo.py | 6 | ||||
| -rw-r--r-- | aptsources/distro.py | 12 | ||||
| -rw-r--r-- | aptsources/sourceslist.py | 4 |
3 files changed, 11 insertions, 11 deletions
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) |
