예제 #1
0
def get_stack():
    d_stack = utils.get_index(utils.repodata())
    f_stack = [
        {
            "type": "TitleSelectOne",
            "name": "Select Stack :",
            "key": "stack",
            "values": d_stack
        },
    ]
    stack = utils.form_generator("Stack list", f_stack)
    try:
        return d_stack[stack["stack"].value[0]]
    except:
        return None
예제 #2
0
def get_stack():
    try:
        d_stack = utils.get_index(utils.repodata())
        f_stack = [
            {
                "type": "TitleSelectOne",
                "name": "Select Stack ",
                "key": "stack",
                "values": d_stack
            },
        ]
        stack = utils.prompt_generator("", f_stack)
        return stack[f_stack[0]["key"]]
    except:
        return None
예제 #3
0
def get_project(templates):
    d_template = utils.get_index(utils.repodata()[templates])
    f_template = [
        {
            "type": "TitleSelectOne",
            "name": "Select template :",
            "key": "template",
            "values": d_template
        },
    ]
    template = utils.form_generator("Templates", f_template)
    try:
        return (d_template[template["template"].value[0]])
    except:
        return None
예제 #4
0
def get_project(templates):
    try:
        d_template = utils.get_index(utils.repodata()[templates])
        f_template = [
            {
                "type": "TitleSelectOne",
                "name": "-------------------",
                "key": "template",
                "values": d_template
            },
        ]
        template = utils.prompt_generator("Select Templates ", f_template)
        return template[f_template[0]["key"]]
    except:
        return None
예제 #5
0
def setup_form(node, stack, project, parent=None):
    init = {
        "form": [{
            "type": "TitleText",
            "name": "Name",
            "key": "name"
        }],
        "depend": [],
        "number": [],
        "stack": stack,
        "project": project,
        "parent": parent
    }

    if parent:
        init["parent"] = parent

    repo = utils.repodata()[stack][project]
    if utils.check_key(repo, "parameters"):
        param = repo["parameters"]
        param_index = utils.get_index(param)
        for index in param_index:
            prop = param[index]
            if not utils.check_key(prop, "default"):
                if not utils.check_key(prop, "dependences"):
                    init["form"].append({
                        "type": "TitleText",
                        "name": prop["label"],
                        "key": index
                    })
                    if prop["type"] == "number":
                        init["number"].append(index)
                else:
                    depend = prop["dependences"]
                    if depend.split(":")[0] == "func":
                        func_name = depend.split(":")[1]
                        init["form"].append({
                            "type":
                            "TitleSelectOne",
                            "name":
                            prop["label"],
                            "key":
                            index,
                            "scroll_exit":
                            True,
                            "values":
                            globals()[func_name](node, "local"),
                            "max_height":
                            7,
                            "value": [
                                0,
                            ]
                        })
                    if depend.split(":")[0] == "repo":
                        repo_name = depend.split(":")[1]
                        init["depend"].append({
                            "name": prop["label"],
                            "key": index,
                            "repo": repo_name
                        })
    return init