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