同步操作将从 华北电力大学-iDeal/Python_RESTfulAPI_Codegen 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python# -*- coding:utf-8 -*-# file:__init__.py.py# author:Nathan# datetime:2021年8月25日 11:12# software: PyCharm"""this is function description"""import osfrom codegen import project_dirfrom config.setting import Settingsfrom utils.common import str_to_little_camel_casefrom utils.loggings import loggingsfrom . import cmddef main(table_dict):"""model层代码的生成:return: None"""try:# 在项目文件夹中创建models的目录os.makedirs(models_path := os.path.join(project_dir, 'models'), exist_ok=True)# 创建空的 __init__.py 文件with open(os.path.join(models_path, '__init__.py'), 'w', encoding='utf-8') as f:f.write("#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n")tables = list(table_dict.keys())# 为每张表生成model层代码for table in tables:loggings.info(1, "Model code for {0} table is being generated".format(table))command = cmd.format(url=Settings.MODEL_URL,schema="",tables=" --tables {0}".format(table),noviews="",noindexes="",noconstraints="",nojoined="",noinflect="",noclasses="",notables="",outfile=" --outfile {0}\{1}".format(models_path, str_to_little_camel_case(table) + "Model.py"),nobackrefs="",nocomments="",ignore_cols="")os.system(command)except Exception as e:loggings.exception(1, e)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。