def init(stack=None, project=None): select_stack = stack while not select_stack: select_stack = get_stack() select_project = project while not select_project: select_project = get_project(select_stack) fields = exec_form(select_stack, select_project) data = list() for field in fields["init"]: f_field = eval(str(field["form"])) validate = False while not validate: f_form = eval(str(field["form"])) form = utils.form_generator("Setup {}".format(field["project"]), f_form) for k, v in form.items(): if isinstance(v.value, list): for role in f_field: if role["key"] == k: form[k] = role["values"][v.value[0]] else: form[k] = v.value if field["parent"]: form["parent"] = field["parent"] else: form["parent"] = None form["stack"] = field["stack"] form["template"] = field["project"] """ Check if data is null """ null_data = 0 for k_data, v_data in form.items(): if v_data == "": null_data += 1 if len(field["number"]) > 0: if k_data in field["number"]: if utils.isint(v_data): form[k_data] = int(v_data) elif utils.isfloat(v_data): form[k_data] = float(v_data) else: null_data += 1 if null_data == 0: validate = True data.append(form) utils.yaml_create("neo.yml", dump(data)) return utils.read_file("neo.yml")
def test_isint(self): assert utils.isint(4) is True assert utils.isint(4.3) is False
def init(stack=None, project=None): select_stack = stack if not select_stack: select_stack = get_stack() select_project = project if not select_project: select_project = get_project(select_stack) fields = exec_form(select_stack, select_project) data = list() for field in fields["init"]: validate = False while not validate: f_form = eval(str(field["form"])) name_type = f_form[0] """ Generate form if just_child_val is False """ if name_type["type"] == "TitleSelect": name_values = name_type["values"] form = utils.prompt_generator( "Setup {}".format(field["project"]), [name_type]) if form["name"] in name_values: form["just_child_val"] = True validate = True else: new_form = eval(str(field["form"])) del new_form[0] new_form_val = utils.prompt_generator( "Setup {}".format(field["project"]), new_form) form.update(new_form_val) form["just_child_val"] = False else: form = utils.prompt_generator( "Setup {}".format(field["project"]), f_form) form["just_child_val"] = False if field["parent"]: form["parent"] = field["parent"] else: form["parent"] = None if not form["just_child_val"]: form["stack"] = field["stack"] form["template"] = field["project"] """ Check if data is null """ null_data = 0 for k_data, v_data in form.items(): if v_data == "": null_data += 1 if len(field["number"]) > 0: if k_data in field["number"]: if utils.isint(v_data): form[k_data] = int(v_data) elif utils.isfloat(v_data): form[k_data] = float(v_data) else: null_data += 1 if null_data == 0: validate = True if validate: data.append(form) if os.name == "nt": os.system("cls") else: os.system("clear") utils.yaml_create("neo.yml", dump(data)) return utils.read_file("neo.yml")
def test_isint_eror(self): assert utils.isint('f') == False
def test_is_init(self): assert utils.isint(1) == True