Mercurial > babel > mirror
annotate scripts/dump_data.py @ 389:a11564c5c1f1 stable-0.9.x
Ported [424], [425], and [428] back to 0.9.x branch.
author | cmlenz |
---|---|
date | Mon, 14 Jul 2008 19:46:19 +0000 |
parents | 0a0bc1639ea7 |
children | ca203b2af83c |
rev | line source |
---|---|
8
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
1 #!/usr/bin/env python |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
3 # |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
4 # Copyright (C) 2007 Edgewall Software |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
5 # All rights reserved. |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
6 # |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
7 # This software is licensed as described in the file COPYING, which |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
8 # you should have received as part of this distribution. The terms |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
9 # are also available at http://babel.edgewall.org/wiki/License. |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
10 # |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
11 # This software consists of voluntary contributions made by many |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
12 # individuals. For the exact contribution history, see the revision |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
13 # history and logs, available at http://babel.edgewall.org/log/. |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
14 |
379 | 15 from optparse import OptionParser |
8
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
16 from pprint import pprint |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
17 import sys |
29f6f9a90f14
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
18 |
379 | 19 from babel.localedata import load, LocaleDataDict |
33 | 20 |
379 | 21 |
22 def main(): | |
23 parser = OptionParser(usage='%prog [options] locale [path]') | |
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] | |
389
a11564c5c1f1
Ported [424], [425], and [428] back to 0.9.x branch.
cmlenz
parents:
379
diff
changeset
|
39 if isinstance(data, dict): |
a11564c5c1f1
Ported [424], [425], and [428] back to 0.9.x branch.
cmlenz
parents:
379
diff
changeset
|
40 data = dict(data.items()) |
a11564c5c1f1
Ported [424], [425], and [428] back to 0.9.x branch.
cmlenz
parents:
379
diff
changeset
|
41 pprint(data) |
379 | 42 |
43 | |
44 if __name__ == '__main__': | |
45 main() |