예제 #1
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:
        try:
            mod = import_mod('esmero.command.%s' % name)
            if hasattr(mod, "DEFAULTS"):
                for var, val in mod.DEFAULTS.iteritems():
                    cfg[name][var] = os.path.expandvars(val)
        except ImportError:
            pass
예제 #2
0
def run():
    """Run esmero from the command line. """
    mod = dict()
    rootpath = pt.split(pt.abspath(__file__))[0]
    mod_names = [name for name in iglob('%s/command/*.py' % rootpath)]
    for name in mod_names:
        tmp_name = pt.split(name)[1][:-3]
        tmp_mod = import_mod('esmero.command.%s' % tmp_name)
        if hasattr(tmp_mod, 'add_parser'):
            mod[tmp_name] = tmp_mod
    arg = parse_options(mod)
    config.CONFIG['cfg_path'] = arg.cfg_path
    config.CONFIG['cfg_user'] = arg.cfg_user
    config.CONFIG['arg'] = arg
    mod[arg.parser_name].run()