| 1 |
#!/usr/bin/env python |
| 2 |
# |
| 3 |
# Copyright (C) 2007-2011 Edgewall Software, 2013-2025 the Babel team |
| 4 |
# All rights reserved. |
| 5 |
# |
| 6 |
# This software is licensed as described in the file LICENSE, which |
| 7 |
# you should have received as part of this distribution. The terms |
| 8 |
# are also available at https://github.com/python-babel/babel/blob/master/LICENSE. |
| 9 |
# |
| 10 |
# This software consists of voluntary contributions made by many |
| 11 |
# individuals. For the exact contribution history, see the revision |
| 12 |
# history and logs, available at https://github.com/python-babel/babel/commits/master/. |
| 13 |
|
| 14 |
from optparse import OptionParser |
| 15 |
from pprint import pprint |
| 16 |
|
| 17 |
from babel.localedata import LocaleDataDict, load |
| 18 |
|
| 19 |
|
| 20 |
def main(): |
| 21 |
parser = OptionParser(usage='%prog [options] locale [path]') |
| 22 |
parser.add_option('--noinherit', action='store_false', dest='inherit', |
| 23 |
help='do not merge inherited data into locale data') |
| 24 |
parser.add_option('--resolve', action='store_true', dest='resolve', |
| 25 |
help='resolve aliases in locale data') |
| 26 |
parser.set_defaults(inherit=True, resolve=False) |
| 27 |
options, args = parser.parse_args() |
| 28 |
if len(args) not in (1, 2): |
| 29 |
parser.error('incorrect number of arguments') |
| 30 |
|
| 31 |
data = load(args[0], merge_inherited=options.inherit) |
| 32 |
if options.resolve: |
| 33 |
data = LocaleDataDict(data) |
| 34 |
if len(args) > 1: |
| 35 |
for key in args[1].split('.'): |
| 36 |
data = data[key] |
| 37 |
if isinstance(data, dict): |
| 38 |
data = dict(data.items()) |
| 39 |
pprint(data) |
| 40 |
|
| 41 |
|
| 42 |
if __name__ == '__main__': |
| 43 |
main() |