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@375: from optparse import OptionParser cmlenz@8: from pprint import pprint cmlenz@8: import sys cmlenz@8: cmlenz@375: from babel.localedata import load, LocaleDataDict cmlenz@33: cmlenz@375: cmlenz@375: def main(): cmlenz@375: parser = OptionParser(usage='%prog [options] locale [path]') cmlenz@375: parser.add_option('--noinherit', action='store_false', dest='inherit', cmlenz@375: help='do not merge inherited data into locale data') cmlenz@375: parser.add_option('--resolve', action='store_true', dest='resolve', cmlenz@375: help='resolve aliases in locale data') cmlenz@375: parser.set_defaults(inherit=True, resolve=False) cmlenz@375: options, args = parser.parse_args() cmlenz@375: if len(args) not in (1, 2): cmlenz@375: parser.error('incorrect number of arguments') cmlenz@375: cmlenz@375: data = load(args[0], merge_inherited=options.inherit) cmlenz@375: if options.resolve: cmlenz@375: data = LocaleDataDict(data) cmlenz@375: if len(args) > 1: cmlenz@375: for key in args[1].split('.'): cmlenz@375: data = data[key] cmlenz@375: pprint(dict(data.items())) cmlenz@375: cmlenz@375: cmlenz@375: if __name__ == '__main__': cmlenz@375: main()