Mercurial > babel > mirror
annotate scripts/dump_data.py @ 593:99983baf1067 trunk
resort to hard-coded message extractors/checkers if pkg_resources is installed but no egg-info was found (#230)
author | fschwarz |
---|---|
date | Thu, 09 Aug 2012 11:20:25 +0000 |
parents | 0d1ca91fc0d5 |
children |
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 # |
530 | 4 # Copyright (C) 2007-2011 Edgewall Software |
8
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 |
375
4eca63af0a12
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:
233
diff
changeset
|
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 |
375
4eca63af0a12
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:
233
diff
changeset
|
18 from babel.localedata import load, LocaleDataDict |
33 | 19 |
375
4eca63af0a12
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:
233
diff
changeset
|
20 |
4eca63af0a12
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:
233
diff
changeset
|
21 def main(): |
4eca63af0a12
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:
233
diff
changeset
|
22 parser = OptionParser(usage='%prog [options] locale [path]') |
4eca63af0a12
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:
233
diff
changeset
|
23 parser.add_option('--noinherit', action='store_false', dest='inherit', |
4eca63af0a12
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:
233
diff
changeset
|
24 help='do not merge inherited data into locale data') |
4eca63af0a12
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:
233
diff
changeset
|
25 parser.add_option('--resolve', action='store_true', dest='resolve', |
4eca63af0a12
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:
233
diff
changeset
|
26 help='resolve aliases in locale data') |
4eca63af0a12
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:
233
diff
changeset
|
27 parser.set_defaults(inherit=True, resolve=False) |
4eca63af0a12
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:
233
diff
changeset
|
28 options, args = parser.parse_args() |
4eca63af0a12
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:
233
diff
changeset
|
29 if len(args) not in (1, 2): |
4eca63af0a12
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:
233
diff
changeset
|
30 parser.error('incorrect number of arguments') |
4eca63af0a12
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:
233
diff
changeset
|
31 |
4eca63af0a12
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:
233
diff
changeset
|
32 data = load(args[0], merge_inherited=options.inherit) |
4eca63af0a12
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:
233
diff
changeset
|
33 if options.resolve: |
4eca63af0a12
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:
233
diff
changeset
|
34 data = LocaleDataDict(data) |
4eca63af0a12
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:
233
diff
changeset
|
35 if len(args) > 1: |
4eca63af0a12
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:
233
diff
changeset
|
36 for key in args[1].split('.'): |
4eca63af0a12
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:
233
diff
changeset
|
37 data = data[key] |
385
38db48990998
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
375
diff
changeset
|
38 if isinstance(data, dict): |
38db48990998
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
375
diff
changeset
|
39 data = dict(data.items()) |
38db48990998
Improve CLDR import of currency-related data to ignore unsupported features such as symbol choice patterns and pluralized display names. See #93.
cmlenz
parents:
375
diff
changeset
|
40 pprint(data) |
375
4eca63af0a12
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:
233
diff
changeset
|
41 |
4eca63af0a12
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:
233
diff
changeset
|
42 |
4eca63af0a12
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:
233
diff
changeset
|
43 if __name__ == '__main__': |
4eca63af0a12
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:
233
diff
changeset
|
44 main() |