[Python-modules-commits] r19112 - in packages/django-countries/trunk/debian/patches (1 file)
fladi-guest at users.alioth.debian.org
fladi-guest at users.alioth.debian.org
Sun Oct 30 22:59:16 UTC 2011
Date: Sunday, October 30, 2011 @ 22:59:15
Author: fladi-guest
Revision: 19112
Sort nodes by country name before building the lists.
Modified:
packages/django-countries/trunk/debian/patches/use_iso_codes_package.patch
Modified: packages/django-countries/trunk/debian/patches/use_iso_codes_package.patch
===================================================================
--- packages/django-countries/trunk/debian/patches/use_iso_codes_package.patch 2011-10-30 22:47:26 UTC (rev 19111)
+++ packages/django-countries/trunk/debian/patches/use_iso_codes_package.patch 2011-10-30 22:59:15 UTC (rev 19112)
@@ -28,19 +28,24 @@
+ISO_XML = _build_iso_xml()
--- a/django_countries/countries.py
+++ b/django_countries/countries.py
-@@ -1,5 +1,25 @@
+@@ -1,5 +1,30 @@
from django.utils.translation import ugettext_lazy as _
+from xml.dom.minidom import parse
++import locale
+
+from django_countries import settings
+
++locale.setlocale(locale.LC_ALL, '')
++
+# Nicely titled (and translated) country names.
+COUNTRIES = []
+COUNTRIES_PLUS = []
+OFFICIAL_COUNTRIES = {}
+
-+for node in parse(settings.ISO_XML).getElementsByTagName('iso_3166_entry'):
++for node in sorted(parse(settings.ISO_XML).getElementsByTagName('iso_3166_entry'),
++ key=lambda node: node.getAttribute('name'),
++ cmp=locale.strcoll):
+ _code = node.getAttribute('alpha_2_code')
+ _name = _(node.getAttribute('name'))
+ COUNTRIES.append((_code, _name))
@@ -54,7 +59,7 @@
# Nicely titled (and translatable) country names.
COUNTRIES = (
('AF', _(u'Afghanistan')),
-@@ -775,3 +795,5 @@
+@@ -775,3 +800,5 @@
'ZM': u'ZAMBIA',
'ZW': u'ZIMBABWE',
}
More information about the Python-modules-commits
mailing list