cmlenz@8: #!/usr/bin/env python cmlenz@8: # -*- coding: utf-8 -*- cmlenz@8: # cmlenz@8: # Copyright (C) 2007 Edgewall Software cmlenz@8: # All rights reserved. cmlenz@8: # cmlenz@8: # This software is licensed as described in the file COPYING, which cmlenz@8: # you should have received as part of this distribution. The terms cmlenz@8: # are also available at http://babel.edgewall.org/wiki/License. cmlenz@8: # cmlenz@8: # This software consists of voluntary contributions made by many cmlenz@8: # individuals. For the exact contribution history, see the revision cmlenz@8: # history and logs, available at http://babel.edgewall.org/log/. cmlenz@8: cmlenz@379: from optparse import OptionParser cmlenz@8: from pprint import pprint cmlenz@8: import sys cmlenz@8: cmlenz@379: from babel.localedata import load, LocaleDataDict cmlenz@33: cmlenz@379: cmlenz@379: def main(): cmlenz@379: parser = OptionParser(usage='%prog [options] locale [path]') cmlenz@379: parser.add_option('--noinherit', action='store_false', dest='inherit', cmlenz@379: help='do not merge inherited data into locale data') cmlenz@379: parser.add_option('--resolve', action='store_true', dest='resolve', cmlenz@379: help='resolve aliases in locale data') cmlenz@379: parser.set_defaults(inherit=True, resolve=False) cmlenz@379: options, args = parser.parse_args() cmlenz@379: if len(args) not in (1, 2): cmlenz@379: parser.error('incorrect number of arguments') cmlenz@379: cmlenz@379: data = load(args[0], merge_inherited=options.inherit) cmlenz@379: if options.resolve: cmlenz@379: data = LocaleDataDict(data) cmlenz@379: if len(args) > 1: cmlenz@379: for key in args[1].split('.'): cmlenz@379: data = data[key] cmlenz@389: if isinstance(data, dict): cmlenz@389: data = dict(data.items()) cmlenz@389: pprint(data) cmlenz@379: cmlenz@379: cmlenz@379: if __name__ == '__main__': cmlenz@379: main()