[Python-modules-commits] r19203 - in packages/django-countries/trunk/debian/patches (1 file)
fladi-guest at users.alioth.debian.org
fladi-guest at users.alioth.debian.org
Wed Nov 9 07:05:35 UTC 2011
Date: Wednesday, November 9, 2011 @ 07:05:29
Author: fladi-guest
Revision: 19203
Use unicode sorting mechanism proposed by Jakub Wilk.
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-11-09 07:03:48 UTC (rev 19202)
+++ packages/django-countries/trunk/debian/patches/use_iso_codes_package.patch 2011-11-09 07:05:29 UTC (rev 19203)
@@ -28,9 +28,10 @@
+ISO_XML = _build_iso_xml()
--- a/django_countries/countries.py
+++ b/django_countries/countries.py
-@@ -1,5 +1,31 @@
+@@ -1,5 +1,35 @@
from django.utils.translation import ugettext_lazy as _
++import unicodedata
+from xml.dom.minidom import parse
+
+from django_countries import settings
@@ -41,8 +42,11 @@
+COUNTRIES_PLUS = []
+OFFICIAL_COUNTRIES = {}
+
++def _sort_key(s):
++ return unicodedata.normalize('NFD', s).encode('ASCII', 'ignore')
++
+for node in sorted(parse(settings.ISO_XML).getElementsByTagName('iso_3166_entry'),
-+ key=lambda node: node.getAttribute('name')):
++ key=lambda node: _sort_key(node.getAttribute('name'))):
+ _code = node.getAttribute('alpha_2_code')
+ _name = _(node.getAttribute('name'))
+ COUNTRIES.append((_code, _name))
@@ -60,7 +64,7 @@
# Nicely titled (and translatable) country names.
COUNTRIES = (
('AF', _(u'Afghanistan')),
-@@ -775,3 +801,5 @@
+@@ -775,3 +805,5 @@
'ZM': u'ZAMBIA',
'ZW': u'ZIMBABWE',
}
More information about the Python-modules-commits
mailing list