Mercurial > babel > old > mirror
annotate scripts/dump_data.py @ 496:6002c8e21ed5
Update ChangeLog.
author | jruigrok |
---|---|
date | Mon, 19 Apr 2010 09:48:56 +0000 |
parents | 88e3589ca8df |
children | e93f68837913 |
rev | line source |
---|---|
10
0ca5dd65594f
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 |
0ca5dd65594f
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 -*- |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
3 # |
0ca5dd65594f
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 |
0ca5dd65594f
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. |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
6 # |
0ca5dd65594f
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 |
0ca5dd65594f
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 |
0ca5dd65594f
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. |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
10 # |
0ca5dd65594f
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 |
0ca5dd65594f
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 |
0ca5dd65594f
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/. |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
14 |
377
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
15 from optparse import OptionParser |
10
0ca5dd65594f
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 |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
17 import sys |
0ca5dd65594f
Pull in some supplemental data from the CLDR, for things like the first day of the week.
cmlenz
parents:
diff
changeset
|
18 |
377
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
19 from babel.localedata import load, LocaleDataDict |
35 | 20 |
377
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
21 |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
22 def main(): |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
23 parser = OptionParser(usage='%prog [options] locale [path]') |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
24 parser.add_option('--noinherit', action='store_false', dest='inherit', |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
25 help='do not merge inherited data into locale data') |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
26 parser.add_option('--resolve', action='store_true', dest='resolve', |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
27 help='resolve aliases in locale data') |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
28 parser.set_defaults(inherit=True, resolve=False) |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
29 options, args = parser.parse_args() |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
30 if len(args) not in (1, 2): |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
31 parser.error('incorrect number of arguments') |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
32 |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
33 data = load(args[0], merge_inherited=options.inherit) |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
34 if options.resolve: |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
35 data = LocaleDataDict(data) |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
36 if len(args) > 1: |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
37 for key in args[1].split('.'): |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
38 data = data[key] |
387
88e3589ca8df
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
377
diff
changeset
|
39 if isinstance(data, dict): |
88e3589ca8df
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
377
diff
changeset
|
40 data = dict(data.items()) |
88e3589ca8df
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
377
diff
changeset
|
41 pprint(data) |
377
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
42 |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
43 |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
44 if __name__ == '__main__': |
841858d5b567
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
235
diff
changeset
|
45 main() |