summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-01-21 22:42:26 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2009-01-21 22:42:26 +0100
commitef6a647b219823bf75cace674904ade03079b2e5 (patch)
tree86fccb12c72d385fa7e3eb7710b679a65ae52a0c
parent96ba2a685e8f754d2917da88dc424ef71a99b2e8 (diff)
downloadpython-apt-ef6a647b219823bf75cace674904ade03079b2e5.tar.gz
* aptsources/distro.py:
- use iso_3166.xml instead of iso_3166.tab * debian/control: - add Recommends to iso-codes (for iso_3166.xml)
-rw-r--r--aptsources/distro.py29
-rw-r--r--debian/changelog9
-rw-r--r--debian/control1
3 files changed, 26 insertions, 13 deletions
diff --git a/aptsources/distro.py b/aptsources/distro.py
index 1d958132..56e95339 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
@@ -161,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
@@ -199,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("/ "))
diff --git a/debian/changelog b/debian/changelog
index 860bacc5..8868468a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+python-apt (0.7.9~exp3) experimental; urgency=low
+
+ * aptsources/distro.py:
+ - use iso_3166.xml instead of iso_3166.tab
+ * debian/control:
+ - add Recommends to iso-codes (for iso_3166.xml)
+
+ --
+
python-apt (0.7.9~exp2) experimental; urgency=low
[ Julian Andres Klode ]
diff --git a/debian/control b/debian/control
index 0cb6e215..0fbc0205 100644
--- a/debian/control
+++ b/debian/control
@@ -11,6 +11,7 @@ Vcs-Bzr: http://bzr.debian.org/apt/python-apt/debian-sid
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