view MoinMoin/i18n/build_meta_py @ 491:be33ecd58d4e

add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc imported from: moin--main--1.5--patch-495
author Thomas Waldmann <tw@waldmann-edv.de>
date Wed, 22 Mar 2006 09:55:32 +0000
parents 77499985c79f
children
line wrap: on
line source
#!/usr/bin/env python
def run():
    import sys
    sys.path.insert(0, '../..')
    from MoinMoin.util import pysupport

    outfile = file("meta.py", "w")
    outwiki = file("meta.wiki", "w")

    outfile.write('''# -*- coding: utf-8 -*-
""" This file contains meta information about available languages, so MoinMoin
    does not need to load all language files to collect those informations.
    
    *** Automatically generated, do not edit - edit *.po instead! ***
"""
# lang: (longname, longname-in-english, encoding, direction, maintainer)
languages = {
''')

    # Create python dictionary of known languages
    for lang in sys.argv[1:]:
        print "Processing %s ..." % lang
        try:
            meta = pysupport.importName(lang, "meta")
        except:
            print "Exception caught while importing %s!" % lang
            continue

        # Encode direction to binary, this will be decoded later by
        # i18n.getDirection.
        # TODO: refactor this to save the direction as simple string
        if meta['direction'] == 'ltr':
            dir = 0
        else:
            dir = 1

        # Translate file name to iso language name. iso names are xx[-xx],
        # but since each langauge is a python module, we use xx[_xx]
        lang = lang.replace('_', '-')

        # decode the language (as it is in file encoding still)
        language = meta['language'].decode(meta['encoding'])
        elanguage = meta['elanguage'].decode(meta['encoding'])
        
        meta.update(locals())

        outf = u''''%(lang)s': (u'%(language)s', u'%(elanguage)s', '%(encoding)s', %(dir)d, """%(maintainer)s""",),\n''' % meta
        outw = u'''|| %(lang)s || %(language)s || TODO || %(maintainer)s ||\n''' % meta
        
        outfile.write(outf.encode('utf-8'))
        outwiki.write(outw.encode('utf-8'))
        del meta

    outfile.write("""}
# EOF
""")

if __name__ == "__main__":
    run()