예제 #1
0
def argparsedToArgument(argsNamespace):
    newArguments = ArgumentTree()
    for key, value in vars(argsNamespace).items():
        if value == None:
            continue
        newArguments.set(value, *argparsedNameToPathMap[key])
    return newArguments
예제 #2
0
파일: CLI.py 프로젝트: laerne/jaminique
def argparsedToArgument( argsNamespace ):
    newArguments = ArgumentTree()
    for key, value in vars( argsNamespace ).items():
        if value == None:
            continue
        newArguments.set( value, *argparsedNameToPathMap[key] )
    return newArguments
예제 #3
0
def loadUserConfiguration():
    config_path = os.path.join(appdirs.user_config_dir('jaminique'),
                               "config.json")

    if os.path.isfile(config_path):
        with open(config_path, 'rt') as configfile:
            return ArgumentTree(configfile)
    else:
        return ArgumentTree()
예제 #4
0
def loadCoreConfiguration():
    from sys import argv
    config_path = os.path.join(os.path.dirname(argv[0]), "config.json")

    if os.path.isfile(config_path):
        with open(config_path, 'rt') as configfile:
            return ArgumentTree(configfile)
    else:
        return ArgumentTree()
예제 #5
0
def buildGUI(arguments=None):
    if arguments == None:
        arguments = ArgumentTree()

    glade_path = os.path.join(glade_prefix, "main_ui.glade")
    builder = Gtk.Builder.new_from_file(glade_path)
    handler = GUIHandler(builder, arguments)

    builder.connect_signals(handler)
    builder.get_object("main_window").show_all()

    return handler, builder
예제 #6
0
def argumentTreeUpdatedOnBase(initialcfgName, cfgMap, recursive=True):
    if initialcfgName not in cfgMap:
        return ArgumentTree()

    currentcfg = cfgMap[initialcfgName].clone()

    if not currentcfg.contains('base'):
        currentcfg.set(initialcfgName, '<base-name>')
        return currentcfg
    else:
        newcfg = None

        if recursive:
            newcfg = argumentTreeUpdatedOnBase(currentcfg.get('base'), cfgMap)
        else:
            newcfg = cfgMap[currentcfg.get('base')].clone()

        currentcfg.unset('base')
        newcfg.update(currentcfg)
        return newcfg
예제 #7
0
 def toSubTree(kv):
     k, v = kv
     return (k, ArgumentTree(v))
예제 #8
0
def loadDefaultArgumentTree():
    cfg = ArgumentTree()
    cfg.update(loadCoreConfiguration())
    cfg.update(loadSystemConfiguration())
    cfg.update(loadUserConfiguration())
    return cfg
예제 #9
0
def loadDefaultArgumentTree():
    cfg = ArgumentTree()
    cfg.update( loadCoreConfiguration() )
    cfg.update( loadSystemConfiguration() )
    cfg.update( loadUserConfiguration() )
    return cfg