Mercurial > babel > old > mirror
comparison 0.9.x/scripts/dump_data.py @ 381:6a0e7205790f stable
Ported [407:415/trunk] back to 0.9.x branch.
author | cmlenz |
---|---|
date | Tue, 08 Jul 2008 21:01:28 +0000 |
parents | 5b7d3f9f7d74 |
children | e69a068990f0 |
comparison
equal
deleted
inserted
replaced
371:4b63ce84c6ae | 381:6a0e7205790f |
---|---|
10 # | 10 # |
11 # This software consists of voluntary contributions made by many | 11 # This software consists of voluntary contributions made by many |
12 # individuals. For the exact contribution history, see the revision | 12 # individuals. For the exact contribution history, see the revision |
13 # history and logs, available at http://babel.edgewall.org/log/. | 13 # history and logs, available at http://babel.edgewall.org/log/. |
14 | 14 |
15 from optparse import OptionParser | |
15 from pprint import pprint | 16 from pprint import pprint |
16 import sys | 17 import sys |
17 | 18 |
18 from babel.localedata import load | 19 from babel.localedata import load, LocaleDataDict |
19 | 20 |
20 if len(sys.argv) > 2: | 21 |
21 pprint(load(sys.argv[1]).get(sys.argv[2])) | 22 def main(): |
22 else: | 23 parser = OptionParser(usage='%prog [options] locale [path]') |
23 pprint(load(sys.argv[1])) | 24 parser.add_option('--noinherit', action='store_false', dest='inherit', |
25 help='do not merge inherited data into locale data') | |
26 parser.add_option('--resolve', action='store_true', dest='resolve', | |
27 help='resolve aliases in locale data') | |
28 parser.set_defaults(inherit=True, resolve=False) | |
29 options, args = parser.parse_args() | |
30 if len(args) not in (1, 2): | |
31 parser.error('incorrect number of arguments') | |
32 | |
33 data = load(args[0], merge_inherited=options.inherit) | |
34 if options.resolve: | |
35 data = LocaleDataDict(data) | |
36 if len(args) > 1: | |
37 for key in args[1].split('.'): | |
38 data = data[key] | |
39 pprint(dict(data.items())) | |
40 | |
41 | |
42 if __name__ == '__main__': | |
43 main() |