openubmc-bingo 0.5.240__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openubmc-bingo might be problematic. Click here for more details.
- bmcgo/__init__.py +12 -0
- bmcgo/bmcgo.py +22 -0
- bmcgo/bmcgo_config.py +176 -0
- bmcgo/cli/__init__.py +10 -0
- bmcgo/cli/cli.py +584 -0
- bmcgo/codegen/__init__.py +14 -0
- bmcgo/codegen/c/__init__.py +9 -0
- bmcgo/codegen/c/annotation.py +52 -0
- bmcgo/codegen/c/argument.py +42 -0
- bmcgo/codegen/c/codegen.py +153 -0
- bmcgo/codegen/c/comment.py +22 -0
- bmcgo/codegen/c/ctype_defination.py +353 -0
- bmcgo/codegen/c/helper.py +87 -0
- bmcgo/codegen/c/interface.py +63 -0
- bmcgo/codegen/c/method.py +82 -0
- bmcgo/codegen/c/property.py +180 -0
- bmcgo/codegen/c/renderer.py +21 -0
- bmcgo/codegen/c/signal.py +64 -0
- bmcgo/codegen/c/template/client.c.mako +145 -0
- bmcgo/codegen/c/template/client.h.mako +36 -0
- bmcgo/codegen/c/template/interface.c.mako +0 -0
- bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
- bmcgo/codegen/c/template/micro_component.c.mako +32 -0
- bmcgo/codegen/c/template/public.c.mako +228 -0
- bmcgo/codegen/c/template/public.h.mako +128 -0
- bmcgo/codegen/c/template/server.c.mako +104 -0
- bmcgo/codegen/c/template/server.h.mako +36 -0
- bmcgo/codegen/lua/.lua-format +7 -0
- bmcgo/codegen/lua/Makefile +101 -0
- bmcgo/codegen/lua/__init__.py +9 -0
- bmcgo/codegen/lua/codegen.py +171 -0
- bmcgo/codegen/lua/proto/Makefile +87 -0
- bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
- bmcgo/codegen/lua/proto/types.proto +52 -0
- bmcgo/codegen/lua/script/check_intfs.py +161 -0
- bmcgo/codegen/lua/script/dto/__init__.py +11 -0
- bmcgo/codegen/lua/script/dto/exception.py +53 -0
- bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
- bmcgo/codegen/lua/script/dto/options.py +33 -0
- bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
- bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
- bmcgo/codegen/lua/script/dto/url_route.py +195 -0
- bmcgo/codegen/lua/script/gen_db_json.py +444 -0
- bmcgo/codegen/lua/script/gen_depends.py +89 -0
- bmcgo/codegen/lua/script/gen_entry.py +263 -0
- bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
- bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
- bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
- bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
- bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
- bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
- bmcgo/codegen/lua/script/gen_schema.py +302 -0
- bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
- bmcgo/codegen/lua/script/loader/__init__.py +11 -0
- bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
- bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
- bmcgo/codegen/lua/script/lua_format.py +62 -0
- bmcgo/codegen/lua/script/mds_util.py +385 -0
- bmcgo/codegen/lua/script/merge_model.py +330 -0
- bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
- bmcgo/codegen/lua/script/proto_loader.py +47 -0
- bmcgo/codegen/lua/script/proto_plugin.py +140 -0
- bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
- bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
- bmcgo/codegen/lua/script/render_utils/base.py +25 -0
- bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
- bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
- bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
- bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
- bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
- bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
- bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
- bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
- bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
- bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
- bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
- bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
- bmcgo/codegen/lua/script/template.py +166 -0
- bmcgo/codegen/lua/script/types_pb2.py +516 -0
- bmcgo/codegen/lua/script/utils.py +663 -0
- bmcgo/codegen/lua/script/validate.py +80 -0
- bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
- bmcgo/codegen/lua/templates/Makefile +114 -0
- bmcgo/codegen/lua/templates/apps/Makefile +261 -0
- bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
- bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
- bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
- bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
- bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
- bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
- bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
- bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
- bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
- bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
- bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
- bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
- bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
- bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
- bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
- bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
- bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
- bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
- bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
- bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
- bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
- bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
- bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
- bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
- bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
- bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
- bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
- bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
- bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
- bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
- bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
- bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
- bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
- bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
- bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
- bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
- bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
- bmcgo/component/__init__.py +10 -0
- bmcgo/component/analysis/analysis.py +183 -0
- bmcgo/component/analysis/build_deps.py +165 -0
- bmcgo/component/analysis/data_deps.py +333 -0
- bmcgo/component/analysis/dep-rules.json +912 -0
- bmcgo/component/analysis/dep_node.py +110 -0
- bmcgo/component/analysis/intf_deps.py +163 -0
- bmcgo/component/analysis/intf_validation.py +254 -0
- bmcgo/component/analysis/rule.py +211 -0
- bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
- bmcgo/component/analysis/sr_validation.py +391 -0
- bmcgo/component/build.py +222 -0
- bmcgo/component/component_dt_version_parse.py +348 -0
- bmcgo/component/component_helper.py +114 -0
- bmcgo/component/coverage/__init__.py +11 -0
- bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
- bmcgo/component/coverage/incremental_cov.py +464 -0
- bmcgo/component/deploy.py +110 -0
- bmcgo/component/gen.py +169 -0
- bmcgo/component/package_info.py +236 -0
- bmcgo/component/template/conanbase.py.mako +278 -0
- bmcgo/component/template/conanfile.deploy.py.mako +40 -0
- bmcgo/component/test.py +947 -0
- bmcgo/errors.py +119 -0
- bmcgo/frame.py +217 -0
- bmcgo/functional/__init__.py +10 -0
- bmcgo/functional/analysis.py +96 -0
- bmcgo/functional/bmc_studio_action.py +98 -0
- bmcgo/functional/check.py +185 -0
- bmcgo/functional/conan_index_build.py +251 -0
- bmcgo/functional/config.py +332 -0
- bmcgo/functional/csr_build.py +724 -0
- bmcgo/functional/deploy.py +263 -0
- bmcgo/functional/diff.py +235 -0
- bmcgo/functional/fetch.py +235 -0
- bmcgo/functional/full_component.py +391 -0
- bmcgo/functional/maintain.py +381 -0
- bmcgo/functional/new.py +166 -0
- bmcgo/functional/schema_valid.py +111 -0
- bmcgo/functional/simple_sign.py +104 -0
- bmcgo/functional/upgrade.py +78 -0
- bmcgo/ipmigen/__init__.py +13 -0
- bmcgo/ipmigen/ctype_defination.py +82 -0
- bmcgo/ipmigen/ipmigen.py +309 -0
- bmcgo/ipmigen/template/cmd.c.mako +366 -0
- bmcgo/ipmigen/template/ipmi.c.mako +25 -0
- bmcgo/ipmigen/template/ipmi.h.mako +51 -0
- bmcgo/logger.py +176 -0
- bmcgo/misc.py +117 -0
- bmcgo/target/app.yml +17 -0
- bmcgo/target/install_sdk.yml +15 -0
- bmcgo/target/personal.yml +53 -0
- bmcgo/target/publish.yml +45 -0
- bmcgo/tasks/__init__.py +11 -0
- bmcgo/tasks/download_buildtools_hm.py +124 -0
- bmcgo/tasks/misc.py +15 -0
- bmcgo/tasks/task.py +354 -0
- bmcgo/tasks/task_build_conan.py +714 -0
- bmcgo/tasks/task_build_rootfs_img.py +595 -0
- bmcgo/tasks/task_buildgppbin.py +88 -0
- bmcgo/tasks/task_buildhpm_ext4.py +82 -0
- bmcgo/tasks/task_create_interface_config.py +122 -0
- bmcgo/tasks/task_download_buildtools.py +99 -0
- bmcgo/tasks/task_download_dependency.py +72 -0
- bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
- bmcgo/tasks/task_packet_to_supporte.py +87 -0
- bmcgo/tasks/task_prepare.py +105 -0
- bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
- bmcgo/utils/__init__.py +10 -0
- bmcgo/utils/buffer.py +128 -0
- bmcgo/utils/combine_json_schemas.py +170 -0
- bmcgo/utils/component_post.py +54 -0
- bmcgo/utils/component_version_check.py +86 -0
- bmcgo/utils/config.py +1067 -0
- bmcgo/utils/fetch_component_code.py +232 -0
- bmcgo/utils/install_manager.py +61 -0
- bmcgo/utils/installations/__init__.py +10 -0
- bmcgo/utils/installations/base_installer.py +70 -0
- bmcgo/utils/installations/install_consts.py +30 -0
- bmcgo/utils/installations/install_plans/bingo.yml +11 -0
- bmcgo/utils/installations/install_workflow.py +50 -0
- bmcgo/utils/installations/installers/apt_installer.py +177 -0
- bmcgo/utils/installations/installers/pip_installer.py +46 -0
- bmcgo/utils/installations/version_util.py +100 -0
- bmcgo/utils/mapping_config_patch.py +443 -0
- bmcgo/utils/perf_analysis.py +114 -0
- bmcgo/utils/tools.py +704 -0
- bmcgo/worker.py +417 -0
- openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
- openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
- openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
- openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
- openubmc_bingo-0.5.240.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
import getopt
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import re
|
|
17
|
+
import stat
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
from mako.template import Template
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def find_all_file(base):
|
|
24
|
+
for root, _, fs in os.walk(base):
|
|
25
|
+
for f in fs:
|
|
26
|
+
if '_' in f:
|
|
27
|
+
continue
|
|
28
|
+
if f.endswith('Collection.json'):
|
|
29
|
+
continue
|
|
30
|
+
else:
|
|
31
|
+
fullname = os.path.join(root, f)
|
|
32
|
+
yield fullname
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def generate_route(resource_path, template, out_dir):
|
|
36
|
+
exclude_file = ['LogEntry']
|
|
37
|
+
redfish_url = [
|
|
38
|
+
'Managers', 'Systems', 'Chassis', 'SessionService',
|
|
39
|
+
'AccountService', 'UpdateService', 'TaskService',
|
|
40
|
+
'EventService', 'Sms', 'Fabrics', 'DataAcquisitionService'
|
|
41
|
+
]
|
|
42
|
+
my_template = Template(filename=template)
|
|
43
|
+
for i in find_all_file(resource_path):
|
|
44
|
+
temp_name = i.split("/")[-1]
|
|
45
|
+
file_name = temp_name.split(".")[0]
|
|
46
|
+
if file_name in exclude_file:
|
|
47
|
+
continue
|
|
48
|
+
with open(i, 'r') as temp:
|
|
49
|
+
load_json = json.load(temp)
|
|
50
|
+
if 'definitions' not in load_json:
|
|
51
|
+
continue
|
|
52
|
+
if file_name not in load_json['definitions']:
|
|
53
|
+
continue
|
|
54
|
+
if 'uris' in load_json['definitions'][file_name]:
|
|
55
|
+
# 拼接uris数组
|
|
56
|
+
temp_list = []
|
|
57
|
+
_format_url(file_name, load_json, redfish_url, temp_list)
|
|
58
|
+
_generate_proto(file_name, my_template, out_dir, temp_list)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _format_url(file_name, load_json, redfish_url, temp_list):
|
|
62
|
+
for url in load_json['definitions'][file_name]['uris']:
|
|
63
|
+
if url == '/redfish/v1':
|
|
64
|
+
continue
|
|
65
|
+
url = url.translate(str.maketrans({'{': ':', '}': ''}))
|
|
66
|
+
temp = url.split('/')[3]
|
|
67
|
+
if temp in redfish_url:
|
|
68
|
+
url = url.replace('/redfish/v1/', '')
|
|
69
|
+
temp_list.append(url)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _generate_proto(file_name, my_template, out_dir, temp_list):
|
|
73
|
+
if len(temp_list) > 0:
|
|
74
|
+
for i, url_temp in enumerate(temp_list):
|
|
75
|
+
dir_temp = out_dir + '/' + url_temp.replace(':', "")
|
|
76
|
+
if not os.path.exists(dir_temp):
|
|
77
|
+
os.makedirs(dir_temp)
|
|
78
|
+
# 生成proto文件
|
|
79
|
+
writer = os.fdopen(os.open(dir_temp + '/' + file_name + '.proto',
|
|
80
|
+
os.O_WRONLY | os.O_CREAT, stat.S_IWUSR), 'w')
|
|
81
|
+
writer.write(re.sub(r"\n\n\n+", "\n\n", my_template.render(
|
|
82
|
+
filename=file_name,
|
|
83
|
+
url=url_temp,
|
|
84
|
+
i=i
|
|
85
|
+
)))
|
|
86
|
+
writer.close()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def main(argv):
|
|
90
|
+
resource_path = ''
|
|
91
|
+
template = ''
|
|
92
|
+
out_dir = ''
|
|
93
|
+
try:
|
|
94
|
+
opts, _ = getopt.getopt(
|
|
95
|
+
argv, "hi:t:d:", ["help", "input=", "tpl=", "dir="])
|
|
96
|
+
except getopt.GetoptError:
|
|
97
|
+
help()
|
|
98
|
+
return
|
|
99
|
+
for opt, arg in opts:
|
|
100
|
+
if opt in ("-h", "--help"):
|
|
101
|
+
usage()
|
|
102
|
+
return
|
|
103
|
+
elif opt in ("-i", "--input"):
|
|
104
|
+
resource_path = arg
|
|
105
|
+
elif opt in ("-t", "--tpl"):
|
|
106
|
+
template = arg
|
|
107
|
+
elif opt in ("-d", "--dir"):
|
|
108
|
+
out_dir = arg
|
|
109
|
+
else:
|
|
110
|
+
raise RuntimeError("不支持的选项: {}".format(opt))
|
|
111
|
+
if not resource_path or not template or not out_dir:
|
|
112
|
+
usage()
|
|
113
|
+
return
|
|
114
|
+
generate_route(resource_path, template, out_dir)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
main(sys.argv[1:])
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'Base', 'Factory', 'RequestLuaUtils', 'ControllerLuaUtils', 'IpmiMessageUtils', 'MessageUtils',
|
|
15
|
+
'UtilsMessageLua', 'ErrorLuaUtils', 'ClientLuaUtils',
|
|
16
|
+
'DbLuaUtils', 'IpmiLuaUtils', 'RedfishProtoUtils', 'ServicesUtils',
|
|
17
|
+
'MdbLuaUtils', 'OldModelLuaUtils', 'ModelLuaUtils', "MdbRegister", 'MessagesLuaUtils', 'PluginLuaUtils'
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
from render_utils.base import Base
|
|
21
|
+
from render_utils.client_lua import ClientLuaUtils
|
|
22
|
+
from render_utils.controller_lua import ControllerLuaUtils
|
|
23
|
+
from render_utils.db_lua import DbLuaUtils
|
|
24
|
+
from render_utils.error_lua import ErrorLuaUtils
|
|
25
|
+
from render_utils.factory import Factory
|
|
26
|
+
from render_utils.ipmi_lua import IpmiLuaUtils
|
|
27
|
+
from render_utils.ipmi_message_lua import IpmiMessageUtils
|
|
28
|
+
from render_utils.mdb_lua import MdbLuaUtils
|
|
29
|
+
from render_utils.message_lua import MessageUtils
|
|
30
|
+
from render_utils.redfish_proto import RedfishProtoUtils
|
|
31
|
+
from render_utils.request_lua import RequestLuaUtils
|
|
32
|
+
from render_utils.service_lua import ServicesUtils
|
|
33
|
+
from render_utils.utils_message_lua import UtilsMessageLua
|
|
34
|
+
from render_utils.old_model_lua import OldModelLuaUtils
|
|
35
|
+
from render_utils.model_lua import ModelLuaUtils
|
|
36
|
+
from render_utils.mdb_register import MdbRegister
|
|
37
|
+
from render_utils.messages_lua import MessagesLuaUtils
|
|
38
|
+
from render_utils.plugin_lua import PluginLuaUtils
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
from abc import abstractmethod
|
|
14
|
+
|
|
15
|
+
from dto.options import Options
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Base:
|
|
19
|
+
def __init__(self, data: dict, options: Options):
|
|
20
|
+
self.data = data
|
|
21
|
+
self.options: Options = options
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def name(self) -> str:
|
|
25
|
+
return ""
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
from utils import Utils
|
|
14
|
+
from dto.options import Options
|
|
15
|
+
from render_utils.base import Base
|
|
16
|
+
from render_utils.factory import Factory
|
|
17
|
+
from render_utils.mdb_register import MdbRegister
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ClientLuaUtils(Base, Utils, MdbRegister):
|
|
21
|
+
def __init__(self, data: dict, options: Options):
|
|
22
|
+
super().__init__(data, options=options)
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def message_type(t):
|
|
26
|
+
if t == ".google.protobuf.Empty":
|
|
27
|
+
return 'nil'
|
|
28
|
+
return t[1:] if t.startswith('.') else t
|
|
29
|
+
|
|
30
|
+
def sig(self, msg_type):
|
|
31
|
+
msg = Utils(self.data, self.options).make_get_message(msg_type)
|
|
32
|
+
return "".join(
|
|
33
|
+
[Utils(self.data, self.options).do_type_to_dbus(p['type'], p['repeated']) for p in msg.get('properties')])
|
|
34
|
+
|
|
35
|
+
def props(self, msg_type):
|
|
36
|
+
msg = Utils(self.data, self.options).make_get_message(msg_type)
|
|
37
|
+
return msg.get('properties')
|
|
38
|
+
|
|
39
|
+
def params(self, msg_type):
|
|
40
|
+
return ", ".join([p['name'] for p in self.props(msg_type)])
|
|
41
|
+
|
|
42
|
+
def cb_name(self, rpc):
|
|
43
|
+
return Utils(self.data, self.options).camel_to_snake('__On' + rpc['name'])
|
|
44
|
+
|
|
45
|
+
def rsp_message(self, rpc):
|
|
46
|
+
return self.message_type(rpc['rsp'])
|
|
47
|
+
|
|
48
|
+
def req_message(self, rpc):
|
|
49
|
+
return self.message_type(rpc['req'])
|
|
50
|
+
|
|
51
|
+
def make_path_with_params(self, path):
|
|
52
|
+
path = self.force_to_colon(path)
|
|
53
|
+
params = self.get_path_params(path)
|
|
54
|
+
if not params:
|
|
55
|
+
return f"'{path}'"
|
|
56
|
+
result = []
|
|
57
|
+
for name in params:
|
|
58
|
+
parts = path.partition(f':{name}')
|
|
59
|
+
result.append(f"'{parts[0]}'")
|
|
60
|
+
result.append(f"path_params['{name}']")
|
|
61
|
+
path = parts[2]
|
|
62
|
+
ret = ' .. '.join(result)
|
|
63
|
+
if path:
|
|
64
|
+
ret += f" .. '{path}'"
|
|
65
|
+
return ret
|
|
66
|
+
|
|
67
|
+
def get_path_arg(self, path, with_comma=True):
|
|
68
|
+
if not self.get_path_params(path):
|
|
69
|
+
return ""
|
|
70
|
+
if with_comma:
|
|
71
|
+
return ", path_params"
|
|
72
|
+
return "path_params"
|
|
73
|
+
|
|
74
|
+
def get_dep_properties(self, properties):
|
|
75
|
+
if properties == ["*"]:
|
|
76
|
+
return ""
|
|
77
|
+
|
|
78
|
+
return ', {"' + '", "'.join(properties) + '"}'
|
|
79
|
+
|
|
80
|
+
def get_path_namespace(self, path):
|
|
81
|
+
if not self.get_path_params(path):
|
|
82
|
+
return f"'{path}'"
|
|
83
|
+
path_with_params = self.make_path_with_params(path)
|
|
84
|
+
if Utils.get_lua_codegen_version() >= 17:
|
|
85
|
+
return f"path_params and ({path_with_params}) or '{path}'"
|
|
86
|
+
prefix = path_with_params.split("/' ..")[0]
|
|
87
|
+
return f"path_params and ({path_with_params}) or {prefix}'"
|
|
88
|
+
|
|
89
|
+
def get_path_patterns(self, paths):
|
|
90
|
+
return MdbRegister.convert_to_lua(self, paths)
|
|
91
|
+
|
|
92
|
+
def get_object_path(self, path):
|
|
93
|
+
if not self.get_path_params(path):
|
|
94
|
+
return f"'{path}'"
|
|
95
|
+
path_with_params = self.make_path_with_params(path)
|
|
96
|
+
return f"path_params and ({path_with_params}) or '{path}'"
|
|
97
|
+
|
|
98
|
+
Factory().register("client.lua.mako", ClientLuaUtils)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
from dto.options import Options
|
|
14
|
+
from render_utils.base import Base
|
|
15
|
+
from render_utils.factory import Factory
|
|
16
|
+
from render_utils.utils_message_lua import UtilsMessageLua
|
|
17
|
+
from render_utils.validate_lua import ValidateLua
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ControllerLuaUtils(Base, ValidateLua, UtilsMessageLua):
|
|
21
|
+
methods = ['get', 'post', 'patch', 'delete']
|
|
22
|
+
|
|
23
|
+
def __init__(self, data: dict, options: Options):
|
|
24
|
+
super().__init__(data, options)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def get_property(properties, prop_name):
|
|
28
|
+
for prop in properties:
|
|
29
|
+
if prop["name"].lower() == prop_name.lower():
|
|
30
|
+
return prop
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def get_lower_case_name(name):
|
|
35
|
+
lst = []
|
|
36
|
+
for index, char in enumerate(name):
|
|
37
|
+
if char.isupper() and index != 0:
|
|
38
|
+
lst.append("_")
|
|
39
|
+
lst.append(char)
|
|
40
|
+
return "".join(lst).lower()
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def get_auth(msg):
|
|
44
|
+
if 'auth' in msg["options"]:
|
|
45
|
+
return ', self.auth(ctx)'
|
|
46
|
+
return ''
|
|
47
|
+
|
|
48
|
+
def get_response(self, msg):
|
|
49
|
+
return self.get_property(msg["properties"], "response")
|
|
50
|
+
|
|
51
|
+
def get_body(self, msg):
|
|
52
|
+
return self.get_property(msg["properties"], "body")
|
|
53
|
+
|
|
54
|
+
def get_formdata_body(self, msg):
|
|
55
|
+
return self.get_property(msg["properties"], "formdatabody")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_header(self, msg):
|
|
59
|
+
return self.get_property(msg["properties"], "header")
|
|
60
|
+
|
|
61
|
+
def get_controller_methods(self, msg):
|
|
62
|
+
result = {}
|
|
63
|
+
for method in self.methods:
|
|
64
|
+
method_prop = self.get_property(msg['nested_type'], method)
|
|
65
|
+
if not method_prop:
|
|
66
|
+
continue
|
|
67
|
+
result[method] = method_prop
|
|
68
|
+
return result
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Factory().register("controller.lua.mako", ControllerLuaUtils)
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
5
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
6
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
7
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
8
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
9
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
10
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
11
|
+
# See the Mulan PSL v2 for more details.
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
from utils import Utils
|
|
15
|
+
from dto.options import Options
|
|
16
|
+
from render_utils.base import Base
|
|
17
|
+
from render_utils.factory import Factory
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DbLuaUtils(Base, Utils):
|
|
21
|
+
TYPE_TO_DB_MAP = {
|
|
22
|
+
"int8": 'IntegerField',
|
|
23
|
+
'uint8': 'IntegerField',
|
|
24
|
+
'int16': 'IntegerField',
|
|
25
|
+
'uint16': 'IntegerField',
|
|
26
|
+
'int32': 'IntegerField',
|
|
27
|
+
'uint32': 'IntegerField',
|
|
28
|
+
'int64': 'IntegerField',
|
|
29
|
+
'uint64': 'IntegerField',
|
|
30
|
+
'double': 'RealField',
|
|
31
|
+
'float': 'RealField',
|
|
32
|
+
'bytes': 'BolbField',
|
|
33
|
+
'string': 'TextField',
|
|
34
|
+
'bool': 'BooleandField',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
per_type_map = {
|
|
38
|
+
'PoweroffPer': 'protect_power_off',
|
|
39
|
+
'ResetPer': 'protect_reset',
|
|
40
|
+
'PermanentPer': 'protect_permanent',
|
|
41
|
+
'TemporaryPer': 'protect_temporary',
|
|
42
|
+
'PoweroffPerRetain': 'protect_power_off_retain',
|
|
43
|
+
'ResetPerRetain': 'protect_reset_retain',
|
|
44
|
+
'TemporaryPerRetain': 'protect_temporary_retain'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def __init__(self, data: dict, options: Options):
|
|
48
|
+
super().__init__(data, options=options)
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def table_name(msg):
|
|
52
|
+
if msg['type'] != 'Message' or not msg['options'] or not msg['options']['table_name']:
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
return msg['options']['table_name']
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def table_max_rows(msg):
|
|
59
|
+
return msg.get('type') == 'Message' and msg.get('options', {}).get('table_max_rows', False)
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def all_persistence(msg):
|
|
63
|
+
if msg['type'] != 'Message' or not msg['options']:
|
|
64
|
+
return 'nil'
|
|
65
|
+
|
|
66
|
+
if 'persistence' in msg['options']:
|
|
67
|
+
return msg['options']['persistence']
|
|
68
|
+
|
|
69
|
+
if 'table_type' in msg['options']:
|
|
70
|
+
if msg['options']['table_type'] in DbLuaUtils.per_type_map:
|
|
71
|
+
return DbLuaUtils.per_type_map[msg['options']['table_type']]
|
|
72
|
+
return 'nil'
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def check_local_per_type(root):
|
|
76
|
+
per_map = {
|
|
77
|
+
"PoweroffPer": False,
|
|
78
|
+
"ResetPer": False,
|
|
79
|
+
"TemporaryPer": False
|
|
80
|
+
}
|
|
81
|
+
for msg in root["data"]:
|
|
82
|
+
table_type = msg["options"].get("table_type", "PoweroffPer")
|
|
83
|
+
if table_type not in per_map:
|
|
84
|
+
continue
|
|
85
|
+
per_map[table_type] = True
|
|
86
|
+
return per_map.values()
|
|
87
|
+
|
|
88
|
+
@staticmethod
|
|
89
|
+
def check_local_per_poweroff(msg):
|
|
90
|
+
if "options" not in msg or "table_type" not in msg["options"]:
|
|
91
|
+
return True
|
|
92
|
+
return "options" in msg and "table_type" in msg["options"] and msg["options"]["table_type"] == "PoweroffPer"
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def check_local_per_reset(msg):
|
|
96
|
+
return "options" in msg and "table_type" in msg["options"] and msg["options"]["table_type"] == "ResetPer"
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def check_local_per_temporary(msg):
|
|
100
|
+
return "options" in msg and "table_type" in msg["options"] and msg["options"]["table_type"] == "TemporaryPer"
|
|
101
|
+
|
|
102
|
+
@staticmethod
|
|
103
|
+
def column_max_len(prop):
|
|
104
|
+
if prop['repeated']:
|
|
105
|
+
return 0
|
|
106
|
+
type_name = prop['type']
|
|
107
|
+
if type_name == "int8" or type_name == 'uint8':
|
|
108
|
+
return 8
|
|
109
|
+
if type_name == "int16" or type_name == 'uint16':
|
|
110
|
+
return 16
|
|
111
|
+
if type_name == "int32" or type_name == 'uint32':
|
|
112
|
+
return 32
|
|
113
|
+
if type_name == "int64" or type_name == 'uint64':
|
|
114
|
+
return 64
|
|
115
|
+
if 'max_len' in prop['options']:
|
|
116
|
+
return prop['options']['max_len']
|
|
117
|
+
return 0
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def unique(prop):
|
|
121
|
+
if 'unique' not in prop['options']:
|
|
122
|
+
return ''
|
|
123
|
+
return f':unique()'
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def primary_key(prop):
|
|
127
|
+
if 'primary_key' not in prop['options']:
|
|
128
|
+
return ''
|
|
129
|
+
return f':primary_key()'
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def persistence_key(prop):
|
|
133
|
+
if 'persistence_ex' in prop['options']:
|
|
134
|
+
val = prop['options']['persistence_ex']
|
|
135
|
+
return f':persistence_key("{val}")'
|
|
136
|
+
|
|
137
|
+
if 'usage' not in prop['options']:
|
|
138
|
+
return ''
|
|
139
|
+
val = ''
|
|
140
|
+
for use_type in prop['options']['usage']:
|
|
141
|
+
if use_type in DbLuaUtils.per_type_map:
|
|
142
|
+
val = DbLuaUtils.per_type_map[use_type]
|
|
143
|
+
break
|
|
144
|
+
if val == '':
|
|
145
|
+
return ''
|
|
146
|
+
|
|
147
|
+
return f':persistence_key("{val}")'
|
|
148
|
+
|
|
149
|
+
@staticmethod
|
|
150
|
+
def allow_null(prop):
|
|
151
|
+
if prop['options'].get('allow_null', False):
|
|
152
|
+
return ':null()'
|
|
153
|
+
return ''
|
|
154
|
+
|
|
155
|
+
@staticmethod
|
|
156
|
+
def extend_field(prop):
|
|
157
|
+
if prop['options'].get('extend_field', False):
|
|
158
|
+
return ':extend_field()'
|
|
159
|
+
return ''
|
|
160
|
+
|
|
161
|
+
@staticmethod
|
|
162
|
+
def deprecated(prop):
|
|
163
|
+
if prop['options'].get('deprecated', False):
|
|
164
|
+
return ':deprecated()'
|
|
165
|
+
return ''
|
|
166
|
+
|
|
167
|
+
@staticmethod
|
|
168
|
+
def critical(prop):
|
|
169
|
+
if prop['options'].get('critical', False):
|
|
170
|
+
return ':critical()'
|
|
171
|
+
return ''
|
|
172
|
+
|
|
173
|
+
def column_type(self, prop):
|
|
174
|
+
type_name = prop['type']
|
|
175
|
+
if type_name in self.TYPE_TO_DB_MAP:
|
|
176
|
+
if prop['repeated']:
|
|
177
|
+
return "JsonField()"
|
|
178
|
+
else:
|
|
179
|
+
return self.TYPE_TO_DB_MAP[type_name] + "()"
|
|
180
|
+
types = Utils(self.data, self.options).load_types(type_name)
|
|
181
|
+
if types and ('type' in types) and types['type'] == 'Enum':
|
|
182
|
+
return f'EnumField({types["package"]}.{types["name"]})'
|
|
183
|
+
return "JsonField()"
|
|
184
|
+
|
|
185
|
+
def max_len(self, prop):
|
|
186
|
+
num = self.column_max_len(prop)
|
|
187
|
+
if num == 0:
|
|
188
|
+
return ''
|
|
189
|
+
return f':max_length({num})'
|
|
190
|
+
|
|
191
|
+
def default(self, class_name, prop):
|
|
192
|
+
if 'default' not in prop['options']:
|
|
193
|
+
return ''
|
|
194
|
+
return f':default({self._convert_default_value(class_name, prop)})'
|
|
195
|
+
|
|
196
|
+
def _convert_default_value(self, class_name, prop):
|
|
197
|
+
d_val = prop['options']['default']
|
|
198
|
+
type_name = prop['type']
|
|
199
|
+
types = Utils(self.data, self.options).load_types(type_name)
|
|
200
|
+
if types and ('type' in types) and types['type'] == 'Enum':
|
|
201
|
+
if isinstance(d_val, list):
|
|
202
|
+
result = "{"
|
|
203
|
+
for val in d_val:
|
|
204
|
+
enum_type = Utils(self.data, self.options).enum_value_name(types["name"], val)
|
|
205
|
+
result += f'{types["package"]}.{types["name"]}.{enum_type},'
|
|
206
|
+
return result + "}"
|
|
207
|
+
value_name = Utils(self.data, self.options).enum_value_name(types["name"], d_val)
|
|
208
|
+
return f'{types["package"]}.{types["name"]}.{value_name}'
|
|
209
|
+
if Utils.get_lua_codegen_version() >= 10:
|
|
210
|
+
if prop.get('repeated') and not isinstance(d_val, list):
|
|
211
|
+
raise RuntimeError(f"model.json中类{class_name}的属性{prop['name']}默认值{d_val}类型与属性类型不一致")
|
|
212
|
+
if isinstance(d_val, list) or isinstance(d_val, dict):
|
|
213
|
+
json_str = json.dumps(d_val).replace("'", "''")
|
|
214
|
+
return f"[['{json_str}']]"
|
|
215
|
+
if type_name == "string" or type_name == 'bytes':
|
|
216
|
+
return f'"\'{d_val}\'"'
|
|
217
|
+
if type_name == "bool":
|
|
218
|
+
return str(bool(d_val)).lower()
|
|
219
|
+
return d_val
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Factory().register("db.lua.mako", DbLuaUtils)
|
|
223
|
+
Factory().register("local_db.lua.mako", DbLuaUtils)
|
|
224
|
+
Factory().register("orm_classes.lua.mako", DbLuaUtils)
|