源代码生成库(过度使用语法)
prestring的Python项目详细描述
这很大程度上受到了srcgen的启发。
(待办事项:温和介绍)
功能
- 用语法生成代码
- 写入字符串后的字符串注入
生成语法
的代码fromprestring.pythonimportPythonModulem=PythonModule()withm.class_("Point",metaclass="InterfaceMeta"):withm.def_("__init__","self","value"):m.stmt("self.value = value")withm.def_("__str__","self"):m.return_("self.value")
输出为。
classPoint(object,metaclass=InterfaceMeta)def__init__(self,value):self.value=valuedef__str__(self):returnself.value
写入字符串后的字符串注入
fromprestring.pythonimportPythonModulem=PythonModule()withm.def_("setup","config"):import_area=m.submodule()m.sep()forkin["a","b","c","d","e"]:import_area.stmt("from .plugins import {k}_plugin",k=k)m.stmt("config.activate({}_plugin)",k)print(m)
defsetup(config):from.pluginsimport(a_plugin,b_plugin,c_plugin,d_plugin,e_plugin)config.activate(a_plugin)config.activate(b_plugin)config.activate(c_plugin)config.activate(d_plugin)config.activate(e_plugin)
0.5.3
- 回滚,python的导入部分输出
0.5.1,0.5.2
- 一些错误修复程序
0.5.0
- 添加prestring.python.transform
0.4.7
- 添加prestring.output.separatedoutput
- 懒散的关键字被排序
0.4.3
- 如果为空则清除(例如,GO模块的导入组)
0.4.2
- 错误修复懒散的参数和关键字
0.4
- 更懒(python模块)
- 惰性对象被缓存
0.3.3
- 性腺功能
0.3.1
- 更懒(GO模块)
0.3.0
- go代码输出支持