diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-01-22 17:14:51 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-01-22 17:14:51 +0100 |
| commit | b604b5d71d702ba8e85f79afbfd67a0637bb7051 (patch) | |
| tree | ccc7a5bcc44305401404d45c334675ae8a7ab179 | |
| parent | 66f9141c1bce95290ea087e1dc2bedeecc0ae156 (diff) | |
| parent | 9ecd5cc188487f6823fb450d1ef4aa3f97fcef7b (diff) | |
| download | python-apt-b604b5d71d702ba8e85f79afbfd67a0637bb7051.tar.gz | |
Merge with mvo
| -rw-r--r-- | apt/__init__.py | 6 | ||||
| -rw-r--r-- | aptsources/distro.py | 214 | ||||
| -rw-r--r-- | debian/changelog | 19 | ||||
| -rw-r--r-- | debian/control | 1 |
4 files changed, 127 insertions, 113 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index 05407aff..e3cfacbe 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -15,6 +15,6 @@ from apt_pkg import SizeToStr, TimeToStr, VersionCompare apt_pkg.init() -import warnings -warnings.warn("apt API not stable yet", FutureWarning) -del warnings +#import warnings +#warnings.warn("apt API not stable yet", FutureWarning) +#del warnings diff --git a/aptsources/distro.py b/aptsources/distro.py index a28396b7..36ab0ff8 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -26,6 +26,7 @@ import re import os import sys +from xml.etree.ElementTree import ElementTree import gettext @@ -78,69 +79,68 @@ class Distribution: # find the distro template for template in self.sourceslist.matcher.templates: - if self.is_codename(template.name) and\ - template.distribution == self.id: + if (self.is_codename(template.name) and + template.distribution == self.id): #print "yeah! found a template for %s" % self.description #print template.description, template.base_uri, \ # template.components self.source_template = template break - if self.source_template is None: - raise NoDistroTemplateException("Error: could not find a " + if self.source_template is None: + raise NoDistroTemplateException("Error: could not find a " "distribution template") - # find main and child sources - media = [] - comps = [] - cdrom_comps = [] - enabled_comps = [] - source_code = [] - for source in self.sourceslist.list: - if source.invalid == False and\ - self.is_codename(source.dist) and\ - source.template 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 \ - source.disabled == False: - self.cdrom_sources.append(source) - cdrom_comps.extend(source.comps) - elif source.uri.startswith("cdrom:") and \ - source.disabled == True: - self.cdrom_sources.append(source) - elif source.type == self.binary_type and \ - source.disabled == False: - self.main_sources.append(source) - comps.extend(source.comps) - media.append(source.uri) - elif source.type == self.binary_type and \ - source.disabled == True: - self.disabled_sources.append(source) - elif source.type == self.source_type \ - and source.disabled == False: - self.source_code_sources.append(source) - elif source.type == self.source_type \ - and source.disabled == True: - self.disabled_sources.append(source) - if source.invalid == False and\ - source.template in self.source_template.children: - if source.disabled == False \ - and source.type == self.binary_type: - self.child_sources.append(source) - elif source.disabled == False \ - and source.type == self.source_type: - self.source_code_sources.append(source) - else: - self.disabled_sources.append(source) - self.download_comps = set(comps) - self.cdrom_comps = set(cdrom_comps) - enabled_comps.extend(comps) - enabled_comps.extend(cdrom_comps) - self.enabled_comps = set(enabled_comps) - self.used_media = set(media) - - self.get_mirrors() + # find main and child sources + media = [] + comps = [] + cdrom_comps = [] + enabled_comps = [] + source_code = [] + for source in self.sourceslist.list: + if (source.invalid == False and + self.is_codename(source.dist) and + source.template 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 + source.disabled == False): + self.cdrom_sources.append(source) + cdrom_comps.extend(source.comps) + elif (source.uri.startswith("cdrom:") and + source.disabled == True): + self.cdrom_sources.append(source) + elif (source.type == self.binary_type and + source.disabled == False): + self.main_sources.append(source) + comps.extend(source.comps) + media.append(source.uri) + elif (source.type == self.binary_type and + source.disabled == True): + self.disabled_sources.append(source) + elif (source.type == self.source_type + and source.disabled == False): + self.source_code_sources.append(source) + elif (source.type == self.source_type and + source.disabled == True): + self.disabled_sources.append(source) + if (source.invalid == False and + source.template in self.source_template.children): + if (source.disabled == False + and source.type == self.binary_type): + self.child_sources.append(source) + elif (source.disabled == False + and source.type == self.source_type): + self.source_code_sources.append(source) + else: + self.disabled_sources.append(source) + self.download_comps = set(comps) + self.cdrom_comps = set(cdrom_comps) + enabled_comps.extend(comps) + enabled_comps.extend(cdrom_comps) + self.enabled_comps = set(enabled_comps) + self.used_media = set(media) + self.get_mirrors() def get_mirrors(self, mirror_template=None): """ @@ -162,16 +162,20 @@ class Distribution: # get a list of country codes and real names self.countries = {} - try: - f = open("/usr/share/iso-codes/iso_3166.tab", "r") - lines = f.readlines() - for line in lines: - parts = line.split("\t") - self.countries[parts[0].lower()] = parts[1].strip() - except: - print "could not open file '%s'" % file - else: - f.close() + fname = "/usr/share/xml/iso-codes/iso_3166.xml" + if os.path.exists(fname): + et = ElementTree(file=fname) + it = et.getiterator('iso_3166_entry') + for elm in it: + if elm.attrib.has_key("common_name"): + descr = elm.attrib["common_name"] + else: + descr = elm.attrib["name"] + if elm.attrib.has_key("alpha_2_code"): + code = elm.attrib["alpha_2_code"] + else: + code = elm.attrib["alpha_3_code"] + self.countries[code.lower()] = gettext.dgettext('iso_3166',descr) # try to guess the nearest mirror from the locale self.country = None @@ -200,9 +204,7 @@ class Distribution: country = server[i+len("://"):l] if country in self.countries: # TRANSLATORS: %s is a country - return _("Server for %s") % \ - gettext.dgettext("iso_3166", - self.countries[country].rstrip()).rstrip() + return _("Server for %s") % self.countries[country] else: return("%s" % server.rstrip("/ ")) @@ -217,15 +219,15 @@ class Distribution: # Store all available servers: # Name, URI, active mirrors = [] - if len(self.used_servers) < 1 or \ - (len(self.used_servers) == 1 and \ - compare_mirrors(self.used_servers[0], self.main_server)): + if (len(self.used_servers) < 1 or + (len(self.used_servers) == 1 and + compare_mirrors(self.used_servers[0], self.main_server))): mirrors.append([_("Main server"), self.main_server, True]) if self.nearest_server: mirrors.append([self._get_mirror_name(self.nearest_server), self.nearest_server, False]) - elif len(self.used_servers) == 1 and not \ - compare_mirrors(self.used_servers[0], self.main_server): + elif (len(self.used_servers) == 1 and not + compare_mirrors(self.used_servers[0], self.main_server)): mirrors.append([_("Main server"), self.main_server, False]) # Only one server is used server = self.used_servers[0] @@ -305,42 +307,42 @@ class Distribution: source.comps.append(comp) comps_per_dist[source.dist].add(comp) - sources = [] - sources.extend(self.main_sources) - sources.extend(self.child_sources) - # store what comps are enabled already per distro (where distro is - # e.g. "dapper", "dapper-updates") - comps_per_dist = {} - comps_per_sdist = {} - for s in sources: - if s.type == self.binary_type: - if s.dist not in comps_per_dist: - comps_per_dist[s.dist] = set() + sources = [] + sources.extend(self.main_sources) + sources.extend(self.child_sources) + # store what comps are enabled already per distro (where distro is + # e.g. "dapper", "dapper-updates") + comps_per_dist = {} + comps_per_sdist = {} + for s in sources: + if s.type == self.binary_type: + 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 s.dist not in comps_per_sdist: - comps_per_sdist[s.dist] = set() + for s in self.source_code_sources: + if s.type == self.source_type: + if s.dist not in comps_per_sdist: + comps_per_sdist[s.dist] = set() map(comps_per_sdist[s.dist].add, s.comps) - # check if there is a main source at all - if len(self.main_sources) < 1: + # check if there is a main source at all + if len(self.main_sources) < 1: + # create a new main source + self.add_source(comps=["%s"%comp]) + else: + # add the comp to all main, child and source code sources + for source in sources: + add_component_only_once(source, comps_per_dist) + + # check if there is a main source code source at all + if self.get_source_code == True: + if len(self.source_code_sources) < 1: # create a new main source - self.add_source(comps=["%s"%comp]) + self.add_source(type=self.source_type, comps=["%s"%comp]) else: # add the comp to all main, child and source code sources - for source in sources: - add_component_only_once(source, comps_per_dist) - - # check if there is a main source code source at all - if self.get_source_code == True: - if len(self.source_code_sources) < 1: - # create a new main source - self.add_source(type=self.source_type, comps=["%s"%comp]) - else: - # add the comp to all main, child and source code sources - for source in self.source_code_sources: - add_component_only_once(source, comps_per_sdist) + for source in self.source_code_sources: + add_component_only_once(source, comps_per_sdist) def disable_component(self, comp): """ @@ -382,8 +384,8 @@ class Distribution: change_server_of_source(source, uri, seen_binary) 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: + if (source.template.base_uri is None or + 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/debian/changelog b/debian/changelog index 4b2406f0..400b15f5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,19 @@ +python-apt (0.7.9~exp3) experimental; urgency=low + + * aptsources/distro.py: + - use iso_3166.xml instead of iso_3166.tab + - fix incorrect indent + * debian/control: + - add Recommends to iso-codes (for iso_3166.xml) + + -- + python-apt (0.7.9~exp2) experimental; urgency=low [ Julian Andres Klode ] * apt/*.py: - Almost complete cleanup of the code - - Fix inconsistent use of tabs and spaces (Closes: #505443) (LP: #297207) + - Remove inconsistent use of tabs and spaces (Closes: #505443) - Improved documentation * apt/debfile.py: - Drop get*() methods, as they are deprecated and were @@ -11,7 +21,7 @@ python-apt (0.7.9~exp2) experimental; urgency=low - Make DscSrcPackage working * apt/gtk/widgets.py: - Fix the code and document the signals - * Introduce new documentation build with Sphinx (Closes: #204818) + * Introduce new documentation build with Sphinx - Contains style Guide (Closes: #481562) - debian/rules: Build the documentation here - setup.py: Remove pydoc building and add new docs. @@ -26,7 +36,6 @@ python-apt (0.7.9~exp2) experimental; urgency=low - Remove the Conflicts on python2.3-apt, python2.4-apt, as they are only needed for oldstable (sarge) - Build-Depend on python-sphinx (>= 0.5) - - Add Vcs-Browser * aptsources/distinfo.py: - Allow @ in mirror urls (Closes: #478171) (LP: #223097) * Merge Ben Finney's whitespace changes (Closes: #481563) @@ -43,7 +52,7 @@ python-apt (0.7.9~exp2) experimental; urgency=low - only add nearest_server and server to the mirrors if they are defined - -- Julian Andres Klode <jak@debian.org> Wed, 14 Jan 2009 14:48:20 +0100 + -- Julian Andres Klode <jak@debian.org> Sun, 11 Jan 2009 20:01:59 +0100 python-apt (0.7.9~exp1) experimental; urgency=low @@ -75,6 +84,8 @@ python-apt (0.7.9~exp1) experimental; urgency=low * setup.py: - build html/ help of the apt and aptsources modules into /usr/share/doc/python-apt/html + * apt/__init__.py: + - remove the future warning -- Michael Vogt <mvo@debian.org> Mon, 15 Dec 2008 14:29:47 +0100 diff --git a/debian/control b/debian/control index 32739d44..41e3af4a 100644 --- a/debian/control +++ b/debian/control @@ -12,6 +12,7 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release +Recommends: iso-codes Priority: optional Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte |
