Ejemplo n.º 1
0
def run(arg):
    """Run command. """
    name = arg.name
    if name in get_lang_names():
        mod = import_mod('excentury.lang.%s' % name)
    else:
        try:
            mod = import_mod('excentury.command.%s' % name)
        except ImportError:
            error('ERROR: invalid command or language: %r\n' % name)
    if hasattr(mod, 'DEFAULTS'):
        for key, val in mod.DEFAULTS.iteritems():
            print '%s = %r' % (key, val)
    else:
        print 'NO DEFAULTS'
Ejemplo n.º 2
0
def _update_single(cfg, name, defaults=None):
    "Helper function for get_cfg."
    if defaults:
        for var, val in defaults.iteritems():
            cfg[name][var] = os.path.expandvars(str(val))
    else:
        mod = import_mod('excentury.command.%s' % name)
        if hasattr(mod, "DEFAULTS"):
            for var, val in mod.DEFAULTS.iteritems():
                cfg[name][var] = os.path.expandvars(val)
Ejemplo n.º 3
0
def run(arg):
    """Run command. """
    mod = import_mod('excentury.lang.%s' % arg.lang)
    usage = 'xcpp inputfile [to] %s [optional argument]' % arg.lang
    raw = argparse.RawDescriptionHelpFormatter
    argp = argparse.ArgumentParser(formatter_class=raw,
                                   usage=usage,
                                   description=textwrap.dedent(mod.DESC),
                                   epilog=textwrap.dedent(EPI % arg.lang))
    mod.add_options(argp)
    argp.parse_args(arg.options, arg)
    filename = _get_filename(arg)
    mod.process_file(arg, filename)
Ejemplo n.º 4
0
def run():
    """Run excentury from the command line. """
    mod = dict()
    rootpath = split(abspath(__file__))[0]

    mod_names = [name for name in iglob('%s/command/*.py' % rootpath)]
    for name in mod_names:
        tmp_name = split(name)[1][:-3]
        tmp_mod = import_mod('excentury.command.%s' % tmp_name)
        if hasattr(tmp_mod, 'add_parser'):
            mod[tmp_name] = tmp_mod

    arg = parse_options(mod)
    mod[arg.parser_name].run(arg)