:see: http://www.unicode.org/cldr/
"""
-from babel.core import *
+from babel.core import UnknownLocaleError, Locale, default_locale, \
+ negotiate_locale, parse_locale
try:
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007-2011 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://babel.edgewall.org/wiki/License.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://babel.edgewall.org/log/.
+
+
+import sys
+
+PY2 = sys.version_info[0] == 2
+
+_identity = lambda x: x
+
+
+if not PY2:
+ text_type = str
+ string_types = (str,)
+ integer_types = (int, )
+
+ iterkeys = lambda d: iter(d.keys())
+ itervalues = lambda d: iter(d.values())
+ iteritems = lambda d: iter(d.items())
+
+ from io import StringIO
+ import cPickle as pickle
+
+ def reraise(tp, value, tb=None):
+ if value.__traceback__ is not tb:
+ raise value.with_traceback(tb)
+ raise value
+
+ implements_to_string = _identity
+
+else:
+ text_type = unicode
+ string_types = (str, unicode)
+ integer_types = (int, long)
+
+ iterkeys = lambda d: d.iterkeys()
+ itervalues = lambda d: d.itervalues()
+ iteritems = lambda d: d.iteritems()
+
+ from cStringIO import StringIO
+ import pickle
+
+ exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
+
+ def implements_to_string(cls):
+ cls.__unicode__ = cls.__str__
+ cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
+ return cls
+++ /dev/null
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007-2011 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.
-
-try:
- import threading
-except ImportError:
- import dummy_threading as threading
-
"""Core locale representation and locale data access."""
import os
-import cPickle as pickle
from babel import localedata
+from babel._compat import pickle
__all__ = ['UnknownLocaleError', 'Locale', 'default_locale', 'negotiate_locale',
'parse_locale']
"""
import os
-import cPickle as pickle
+import threading
from UserDict import DictMixin
-from babel.compat import threading
+from babel._compat import pickle
__all__ = ['exists', 'locale_identifiers', 'load']
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
-import cPickle as pickle
from optparse import OptionParser
import os
import re
from babel import dates, numbers
from babel.plural import PluralRule
from babel.localedata import Alias
+from babel._compat import pickle
parse = ElementTree.parse
weekdays = {'mon': 0, 'tue': 1, 'wed': 2, 'thu': 3, 'fri': 4, 'sat': 5,
try:
date_formats[elem.attrib.get('type')] = \
dates.parse_pattern(unicode(elem.findtext('dateFormat/pattern')))
- except ValueError, e:
+ except ValueError as e:
error(e)
elif elem.tag == 'alias':
date_formats = Alias(_translate_alias(
try:
time_formats[elem.attrib.get('type')] = \
dates.parse_pattern(unicode(elem.findtext('timeFormat/pattern')))
- except ValueError, e:
+ except ValueError as e:
error(e)
elif elem.tag == 'alias':
time_formats = Alias(_translate_alias(
try:
datetime_formats[elem.attrib.get('type')] = \
unicode(elem.findtext('dateTimeFormat/pattern'))
- except ValueError, e:
+ except ValueError as e:
error(e)
elif elem.tag == 'alias':
datetime_formats = Alias(_translate_alias(