comparison scripts/import_cldr.py @ 567:c81a11cb1476 trunk

add a compat module to shield the code from changes in different versions of Python
author fschwarz
date Mon, 26 Sep 2011 09:42:43 +0000
parents 1de26da5aa25
children 8ce41e60f90d
comparison
equal deleted inserted replaced
566:593157da23f3 567:c81a11cb1476
15 import cPickle as pickle 15 import cPickle as pickle
16 from optparse import OptionParser 16 from optparse import OptionParser
17 import os 17 import os
18 import re 18 import re
19 import sys 19 import sys
20 try:
21 from xml.etree.ElementTree import parse
22 except ImportError:
23 from elementtree.ElementTree import parse
24 20
25 # Make sure we're using Babel source, and not some previously installed version 21 # Make sure we're using Babel source, and not some previously installed version
26 sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '..')) 22 sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '..'))
27 23
28 from babel import dates, numbers 24 from babel import dates, numbers
25 from babel.compat import any, ElementTree
29 from babel.plural import PluralRule 26 from babel.plural import PluralRule
30 from babel.localedata import Alias 27 from babel.localedata import Alias
31 28
29 parse = ElementTree.parse
32 weekdays = {'mon': 0, 'tue': 1, 'wed': 2, 'thu': 3, 'fri': 4, 'sat': 5, 30 weekdays = {'mon': 0, 'tue': 1, 'wed': 2, 'thu': 3, 'fri': 4, 'sat': 5,
33 'sun': 6} 31 'sun': 6}
34
35 try:
36 any
37 except NameError:
38 def any(iterable):
39 return filter(None, list(iterable))
40 32
41 33
42 def _text(elem): 34 def _text(elem):
43 buf = [elem.text or ''] 35 buf = [elem.text or '']
44 for child in elem: 36 for child in elem:
Copyright (C) 2012-2017 Edgewall Software