自动生成Interface

This commit is contained in:
HuangJiaLuo 2021-09-20 20:51:56 +08:00
parent b03d096b53
commit 09b8907085
1 changed files with 14 additions and 12 deletions

View File

@ -65,19 +65,21 @@ def set_structure_const_template(conf: dict):
def set_structure_interface(conf): def set_structure_interface(conf):
print(conf) text = load_template("interface.template")
Dic = {}
# class KeyInterFace template = Template(text)
for i in conf.keys():
with open(f"{structurePath}/interface.go") as fp: x = i.lower().title()
interfaceText = fp.read() Dic["".join(x.split("_"))] = conf[i]
yamlData = [Dic]
for key, item in conf.items(): text = template.render(Data=yamlData)
interfaceKey = "".join([k.capitalize() for k in key.split('_')]) temp_path = f"{structurePath}/interface.gen.go"
interfaceTitle = "type " with open(temp_path, 'w', encoding='utf-8') as f:
f.write(text)
if __name__ == "__main__": if __name__ == "__main__":
conf, cfg_camel = load_conf() conf, cfg_camel = load_conf()
set_structure_const_template(conf) # set_structure_const_template(conf)
set_structure_interface(conf) # set_structure_interface(conf)
set_structure_interface(cfg_camel)