openubmc-bingo 0.5.257__py3-none-any.whl → 0.5.261__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 +1 -1
- bmcgo/codegen/lua/codegen.py +23 -0
- bmcgo/codegen/lua/script/model_consistency_check.py +242 -0
- bmcgo/codegen/lua/script/render_utils/__init__.py +7 -4
- bmcgo/codegen/lua/script/render_utils/client_lua.py +1 -2
- bmcgo/codegen/lua/script/render_utils/message_lua.py +2 -1
- bmcgo/codegen/lua/script/render_utils/service_lua.py +1 -1
- bmcgo/codegen/lua/script/utils.py +12 -3
- bmcgo/codegen/lua/templates/apps/Makefile +59 -2
- bmcgo/codegen/lua/v1/script/render_utils/client_lua.py +108 -0
- bmcgo/codegen/lua/v1/script/render_utils/db_lua.py +223 -0
- bmcgo/codegen/lua/v1/templates/apps/client.lua.mako +25 -10
- bmcgo/codegen/lua/v1/templates/apps/db.lua.mako +62 -0
- bmcgo/codegen/lua/v1/templates/apps/local_db.lua.mako +184 -0
- bmcgo/codegen/lua/v1/templates/apps/message.lua.mako +35 -0
- bmcgo/codegen/lua/v1/templates/apps/service.lua.mako +5 -6
- bmcgo/codegen/lua/v1/templates/apps/utils/mdb_intf.lua.mako +27 -0
- bmcgo/codegen/lua/v1/templates/apps/utils/mdb_obj.lua.mako +14 -0
- {openubmc_bingo-0.5.257.dist-info → openubmc_bingo-0.5.261.dist-info}/METADATA +1 -1
- {openubmc_bingo-0.5.257.dist-info → openubmc_bingo-0.5.261.dist-info}/RECORD +24 -16
- /bmcgo/codegen/lua/script/{render_utils/mdb_register.py → mdb_register.py} +0 -0
- {openubmc_bingo-0.5.257.dist-info → openubmc_bingo-0.5.261.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.5.257.dist-info → openubmc_bingo-0.5.261.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.5.257.dist-info → openubmc_bingo-0.5.261.dist-info}/top_level.txt +0 -0
bmcgo/__init__.py
CHANGED
bmcgo/codegen/lua/codegen.py
CHANGED
|
@@ -15,6 +15,7 @@ import os
|
|
|
15
15
|
import re
|
|
16
16
|
import subprocess
|
|
17
17
|
import shutil
|
|
18
|
+
from pathlib import Path
|
|
18
19
|
from bmcgo.codegen.c.helper import Helper
|
|
19
20
|
from bmcgo import misc
|
|
20
21
|
from bmcgo.utils.tools import Tools
|
|
@@ -98,6 +99,27 @@ class CodeGen(object):
|
|
|
98
99
|
shutil.copytree(os.path.join(temp_dir, "mdb_interface/opt/bmc/apps/mdb_interface"), target_dir)
|
|
99
100
|
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
100
101
|
|
|
102
|
+
def setup_latest_mdb_interface(self):
|
|
103
|
+
target_dir = os.path.join(self.project_dir, 'temp/opt/bmc/apps/latest_mdb_interface')
|
|
104
|
+
shutil.rmtree(target_dir, ignore_errors=True)
|
|
105
|
+
temp_dir = os.path.join(self.project_dir, 'temp/.latest_mdb_interface_temp')
|
|
106
|
+
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
107
|
+
os.makedirs(temp_dir, exist_ok=True)
|
|
108
|
+
|
|
109
|
+
conan_home = Path(os.environ.get("CONAN_HOME", Path.home() / ".conan/data"))
|
|
110
|
+
mdb_interface_tmp_dir = os.path.join(conan_home, "latest_mdb_interface")
|
|
111
|
+
env = dict(os.environ, CONAN_STORAGE_PATH=mdb_interface_tmp_dir)
|
|
112
|
+
|
|
113
|
+
package = self.get_mdb_interface_package()
|
|
114
|
+
cmd = ["conan", "install", package, f"-if={temp_dir}", "--update", "--build=missing", "-g", "deploy"]
|
|
115
|
+
cmd += ["-pr=profile.dt.ini", "-s", "build_type=Dt"]
|
|
116
|
+
if self.remote:
|
|
117
|
+
cmd += ["-r", self.remote]
|
|
118
|
+
|
|
119
|
+
subprocess.run(cmd, env=env)
|
|
120
|
+
shutil.copytree(os.path.join(temp_dir, "mdb_interface/opt/bmc/apps/mdb_interface"), target_dir)
|
|
121
|
+
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
122
|
+
|
|
101
123
|
def is_valid_date(self, date_str):
|
|
102
124
|
pattern = r'^-- Create: \d{4}-\d{1,2}-\d{1,2}$'
|
|
103
125
|
return bool(re.match(pattern, date_str))
|
|
@@ -141,6 +163,7 @@ class CodeGen(object):
|
|
|
141
163
|
shutil.rmtree(self.gen_tool_dir, ignore_errors=True)
|
|
142
164
|
shutil.copytree(cwd, self.gen_tool_dir)
|
|
143
165
|
self.setup_mdb_interface()
|
|
166
|
+
self.setup_latest_mdb_interface()
|
|
144
167
|
lua_format = self.get_lua_format()
|
|
145
168
|
cmd = [
|
|
146
169
|
"/usr/bin/make", "-j12", f"PROJECT_NAME={self.project_name}", f"TPL_DIR={self.gen_tool_dir}",
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
# Copyright (c) 2025 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
|
+
import logging
|
|
15
|
+
import getopt
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
import stat
|
|
19
|
+
from collections import OrderedDict
|
|
20
|
+
import mds_util as utils
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
MDB_INTF_ITEM = ["properties", "methods", "signals"]
|
|
24
|
+
MDB_METHOD_KEY = ["baseType", "items", "minimum", "maximum", "minLength", "maxLength", "pattern", "enum"]
|
|
25
|
+
MDB_PROPERTY_KEY = MDB_METHOD_KEY + ["readOnly", "deprecated", "constrait"]
|
|
26
|
+
OBJECT_PROPERTIES_INTERFACE = "bmc.kepler.Object.Properties"
|
|
27
|
+
BASETYPE = "baseType"
|
|
28
|
+
REQ = "req"
|
|
29
|
+
RSP = "rsp"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MethodCheckArgs:
|
|
33
|
+
def __init__(self, mdb_data, complete_data, class_name, intf_name, method, param_type):
|
|
34
|
+
self.mdb_data = mdb_data
|
|
35
|
+
self.complete_data = complete_data
|
|
36
|
+
self.class_name = class_name
|
|
37
|
+
self.intf_name = intf_name
|
|
38
|
+
self.method = method
|
|
39
|
+
self.param_type = param_type
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_parent_path(origin_model, class_data):
|
|
43
|
+
if "parent" in class_data and class_data["parent"] in origin_model and \
|
|
44
|
+
"path" in origin_model[class_data["parent"]]:
|
|
45
|
+
return get_parent_path(origin_model, origin_model[class_data["parent"]]) \
|
|
46
|
+
+ "/" + utils.cut_ids(class_data["path"])
|
|
47
|
+
else:
|
|
48
|
+
return utils.cut_ids(class_data["path"])
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def check_prop_consistency(mdb_item, complete_item, class_name, intf_name, prop_keys):
|
|
52
|
+
for prop in prop_keys:
|
|
53
|
+
if BASETYPE in mdb_item[prop] and BASETYPE in complete_item[prop]:
|
|
54
|
+
if mdb_item[prop][BASETYPE] != complete_item[prop][BASETYPE]:
|
|
55
|
+
raise RuntimeError(f"组件模型中类{class_name}接口{intf_name}的属性{prop}的类型{complete_item[prop][BASETYPE]}"
|
|
56
|
+
f"与mdb_interface对应类型{mdb_item[prop][BASETYPE]}不一致"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def check_method_params(args):
|
|
61
|
+
mdb_keys = set(args.mdb_data.keys())
|
|
62
|
+
complete_keys = set(args.complete_data.keys())
|
|
63
|
+
label = "请求" if args.param_type == REQ else "响应"
|
|
64
|
+
if mdb_keys != complete_keys:
|
|
65
|
+
only_in_mdb = mdb_keys - complete_keys
|
|
66
|
+
if only_in_mdb:
|
|
67
|
+
raise RuntimeError(f"组件模型中类{args.class_name}接口{args.intf_name}的方法{args.method}中的{label}参数{only_in_mdb}"
|
|
68
|
+
f"未实现,请检查model.json与mdb_interface定义"
|
|
69
|
+
)
|
|
70
|
+
only_in_complete = complete_keys - mdb_keys
|
|
71
|
+
if only_in_complete:
|
|
72
|
+
raise RuntimeError(f"组件模型中类{args.class_name}接口{args.intf_name}的方法{args.method}中的{label}参数{only_in_complete}"
|
|
73
|
+
f"未在mdb_interface中定义,请检查model.json与mdb_interface定义"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
for param in mdb_keys:
|
|
77
|
+
if BASETYPE in args.mdb_data[param] and BASETYPE in args.complete_data[param]:
|
|
78
|
+
if args.mdb_data[param][BASETYPE] != args.complete_data[param][BASETYPE]:
|
|
79
|
+
raise RuntimeError(f"组件模型中类{args.class_name}接口{args.intf_name}的方法{args.method}中的{label}参数{param}的类型"
|
|
80
|
+
f"{args.complete_data[param][BASETYPE]}与mdb_interface对应类型{args.mdb_data[param][BASETYPE]}不一致"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def check_method_consistency(mdb_item, complete_item, class_name, intf_name, method_keys):
|
|
85
|
+
for method in method_keys:
|
|
86
|
+
has_req_mdb = REQ in mdb_item[method]
|
|
87
|
+
has_req_complete = REQ in complete_item[method]
|
|
88
|
+
if has_req_mdb != has_req_complete:
|
|
89
|
+
if has_req_mdb:
|
|
90
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的方法{method}中未实现req,请检查model.json与mdb_interface定义")
|
|
91
|
+
else:
|
|
92
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的方法{method}中req未在mdb_interface中定义"
|
|
93
|
+
f",请检查model.json与mdb_interface定义"
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
if has_req_mdb:
|
|
97
|
+
method_req_params = MethodCheckArgs(mdb_item[method][REQ], complete_item[method][REQ], \
|
|
98
|
+
class_name, intf_name, method, REQ)
|
|
99
|
+
check_method_params(method_req_params)
|
|
100
|
+
|
|
101
|
+
has_rsp_mdb = RSP in mdb_item[method]
|
|
102
|
+
has_rsp_complete = RSP in complete_item[method]
|
|
103
|
+
if has_rsp_mdb != has_rsp_complete:
|
|
104
|
+
if has_rsp_mdb:
|
|
105
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的方法{method}中未实现rsp参数"
|
|
106
|
+
f",请检查model.json与mdb_interface定义"
|
|
107
|
+
)
|
|
108
|
+
else:
|
|
109
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的方法{method}中rsp未在mdb_interface中定义"
|
|
110
|
+
f",请检查model.json与mdb_interface定义"
|
|
111
|
+
)
|
|
112
|
+
else:
|
|
113
|
+
if has_rsp_mdb:
|
|
114
|
+
method_rsp_params = MethodCheckArgs(mdb_item[method][RSP], complete_item[method][RSP], \
|
|
115
|
+
class_name, intf_name, method, RSP)
|
|
116
|
+
check_method_params(method_rsp_params)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def check_intf_item_consistency(mdb_item, complete_item, class_name, intf_name, item_type):
|
|
120
|
+
mdb_keys = set(mdb_item.keys())
|
|
121
|
+
complete_keys = set(complete_item.keys())
|
|
122
|
+
diff_keys = mdb_keys.symmetric_difference(complete_keys)
|
|
123
|
+
if diff_keys:
|
|
124
|
+
only_in_mdb = diff_keys - complete_keys
|
|
125
|
+
only_in_complete = diff_keys - mdb_keys
|
|
126
|
+
if only_in_mdb:
|
|
127
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的{item_type}未实现{only_in_mdb}"
|
|
128
|
+
f",请检查model.json与mdb_interface定义"
|
|
129
|
+
)
|
|
130
|
+
if only_in_complete:
|
|
131
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的{item_type}中的{only_in_complete}"
|
|
132
|
+
f"未在mdb_interface中定义,请检查model.json与mdb_interface定义"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if item_type == "properties":
|
|
136
|
+
check_prop_consistency(mdb_item, complete_item, class_name, intf_name, mdb_keys)
|
|
137
|
+
elif item_type == "methods":
|
|
138
|
+
check_method_consistency(mdb_item, complete_item, class_name, intf_name, mdb_keys)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def check_intf_consistency(mdb_intf, complete_intf, class_name, intf_name):
|
|
142
|
+
for item in MDB_INTF_ITEM:
|
|
143
|
+
if item in mdb_intf and item not in complete_intf:
|
|
144
|
+
if mdb_intf[item]:
|
|
145
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}未实现{item},请检查model.json与mdb_interface定义")
|
|
146
|
+
elif item not in mdb_intf and item in complete_intf:
|
|
147
|
+
if complete_intf[item]:
|
|
148
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_name}的{item}未在mdb_interface中定义"
|
|
149
|
+
f",请检查model.json与mdb_interface定义"
|
|
150
|
+
)
|
|
151
|
+
elif item in mdb_intf and item in complete_intf:
|
|
152
|
+
check_intf_item_consistency(mdb_intf[item], complete_intf[item], class_name, intf_name, item)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def check_model_consistency(class_name, complete_model, mdb_obj, mdb_path):
|
|
156
|
+
intf_complete = set(complete_model["interfaces"].keys())
|
|
157
|
+
intf_mdb = set(mdb_obj[class_name]["interfaces"])
|
|
158
|
+
if intf_complete != intf_mdb:
|
|
159
|
+
intf_only_in_mds = intf_complete - intf_mdb
|
|
160
|
+
intf_only_in_mds.discard(OBJECT_PROPERTIES_INTERFACE)
|
|
161
|
+
if intf_only_in_mds:
|
|
162
|
+
raise RuntimeError(f"组件模型中类{class_name}的接口{intf_only_in_mds}未在mdb_interface中定义"
|
|
163
|
+
f",请检查model.json与mdb_interface定义"
|
|
164
|
+
)
|
|
165
|
+
intf_only_in_mdb = intf_mdb - intf_complete
|
|
166
|
+
if intf_only_in_mdb:
|
|
167
|
+
raise RuntimeError(f"组件模型中类{class_name}未实现{intf_only_in_mdb}接口,请检查model.json与mdb_interface定义")
|
|
168
|
+
|
|
169
|
+
for intf_name in intf_complete:
|
|
170
|
+
mdb_intf_json = utils.get_intf(intf_name, mdb_path)
|
|
171
|
+
check_intf_consistency(mdb_intf_json[intf_name], complete_model["interfaces"][intf_name], class_name, intf_name)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def check(if_name, mdb_path):
|
|
175
|
+
load_dict = {}
|
|
176
|
+
if os.path.exists(if_name):
|
|
177
|
+
load_f = os.fdopen(os.open(if_name, os.O_RDONLY, stat.S_IRUSR), "r")
|
|
178
|
+
load_dict = OrderedDict(json.load(load_f))
|
|
179
|
+
load_f.close()
|
|
180
|
+
|
|
181
|
+
for class_name, class_data in load_dict.items():
|
|
182
|
+
if "path" in class_data and class_name != "defs":
|
|
183
|
+
class_path = get_parent_path(load_dict, class_data)
|
|
184
|
+
mdb_obj = utils.get_path(class_name, mdb_path, class_path)
|
|
185
|
+
check_model_consistency(class_name, class_data, mdb_obj, mdb_path)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def get_all_modelx_json(mds_dir):
|
|
189
|
+
load_dict = {}
|
|
190
|
+
for root, _, files in os.walk(mds_dir):
|
|
191
|
+
for file in files:
|
|
192
|
+
if file == 'modelx.json':
|
|
193
|
+
file_path = os.path.join(root, file)
|
|
194
|
+
load_f = os.fdopen(os.open(file_path, os.O_RDONLY, stat.S_IRUSR), "r")
|
|
195
|
+
load_modelx_dict = OrderedDict(json.load(load_f))
|
|
196
|
+
load_dict.update(load_modelx_dict)
|
|
197
|
+
|
|
198
|
+
return load_dict
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def access_check(mds_dir, mdb_path):
|
|
202
|
+
load_dict = get_all_modelx_json(mds_dir)
|
|
203
|
+
|
|
204
|
+
for class_name, class_data in load_dict.items():
|
|
205
|
+
if "path" in class_data and class_name != "defs":
|
|
206
|
+
class_path = get_parent_path(load_dict, class_data)
|
|
207
|
+
mdb_obj = utils.get_path(class_name, mdb_path, class_path)
|
|
208
|
+
check_model_consistency(class_name, class_data, mdb_obj, mdb_path)
|
|
209
|
+
|
|
210
|
+
return True
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def usage():
|
|
214
|
+
logging.info("model_consistency_check.py -i <inputfile> -d <MdbInterfaceDir>")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def main(argv):
|
|
218
|
+
m_input = ""
|
|
219
|
+
mdb_path = ""
|
|
220
|
+
try:
|
|
221
|
+
opts, _ = getopt.getopt(argv, "hi:d:", ["help", "input=", "mdb_interface_path="])
|
|
222
|
+
except getopt.GetoptError:
|
|
223
|
+
help()
|
|
224
|
+
return
|
|
225
|
+
for opt, arg in opts:
|
|
226
|
+
if opt in ("-h", "--help"):
|
|
227
|
+
usage()
|
|
228
|
+
return
|
|
229
|
+
elif opt in ("-i", "--input"):
|
|
230
|
+
m_input = arg
|
|
231
|
+
elif opt in ("-d", "--dir"):
|
|
232
|
+
mdb_path = arg
|
|
233
|
+
else:
|
|
234
|
+
raise RuntimeError("不支持的选项: {}".format(opt))
|
|
235
|
+
if not m_input:
|
|
236
|
+
usage()
|
|
237
|
+
return
|
|
238
|
+
check(m_input, mdb_path)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if __name__ == "__main__":
|
|
242
|
+
main(sys.argv[1:])
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
14
|
'Base', 'Factory', 'RequestLuaUtils', 'ControllerLuaUtils', 'IpmiMessageUtils', 'MessageUtils',
|
|
15
|
-
'UtilsMessageLua', 'ErrorLuaUtils', 'ClientLuaUtils', "ConsistencyModelLuaUtils",
|
|
15
|
+
'UtilsMessageLua', 'ErrorLuaUtils', 'ClientLuaUtils', "ConsistencyModelLuaUtils", "ConsistencyDbLuaUtils",
|
|
16
16
|
'DbLuaUtils', 'IpmiLuaUtils', 'RedfishProtoUtils', 'ServicesUtils',
|
|
17
|
-
'MdbLuaUtils', 'OldModelLuaUtils', 'ModelLuaUtils', "MdbRegister", 'MessagesLuaUtils', 'PluginLuaUtils'
|
|
17
|
+
'MdbLuaUtils', 'OldModelLuaUtils', 'ModelLuaUtils', "MdbRegister", 'MessagesLuaUtils', 'PluginLuaUtils',
|
|
18
|
+
'ConsistencyClientLuaUtils'
|
|
18
19
|
]
|
|
19
20
|
|
|
20
21
|
from render_utils.client_lua import ClientLuaUtils
|
|
@@ -31,9 +32,11 @@ from render_utils.service_lua import ServicesUtils
|
|
|
31
32
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
32
33
|
from render_utils.old_model_lua import OldModelLuaUtils
|
|
33
34
|
from render_utils.model_lua import ModelLuaUtils
|
|
34
|
-
from render_utils.mdb_register import MdbRegister
|
|
35
35
|
from render_utils.messages_lua import MessagesLuaUtils
|
|
36
36
|
from render_utils.plugin_lua import PluginLuaUtils
|
|
37
|
+
from bmcgo.codegen.lua.script.mdb_register import MdbRegister
|
|
37
38
|
from bmcgo.codegen.lua.script.base import Base
|
|
38
39
|
from bmcgo.codegen.lua.script.factory import Factory
|
|
39
|
-
from bmcgo.codegen.lua.v1.script.render_utils.model_lua import ConsistencyModelLuaUtils
|
|
40
|
+
from bmcgo.codegen.lua.v1.script.render_utils.model_lua import ConsistencyModelLuaUtils
|
|
41
|
+
from bmcgo.codegen.lua.v1.script.render_utils.db_lua import ConsistencyDbLuaUtils
|
|
42
|
+
from bmcgo.codegen.lua.v1.script.render_utils.client_lua import ConsistencyClientLuaUtils
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
from utils import Utils
|
|
14
14
|
from dto.options import Options
|
|
15
|
-
from
|
|
15
|
+
from bmcgo.codegen.lua.script.mdb_register import MdbRegister
|
|
16
16
|
from bmcgo.codegen.lua.script.base import Base
|
|
17
17
|
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
18
|
|
|
@@ -96,4 +96,3 @@ class ClientLuaUtils(Base, Utils, MdbRegister):
|
|
|
96
96
|
return f"path_params and ({path_with_params}) or '{path}'"
|
|
97
97
|
|
|
98
98
|
Factory().register("client.lua.mako", ClientLuaUtils)
|
|
99
|
-
Factory().register("v1/templates/apps/client.lua.mako", ClientLuaUtils)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
from dto.options import Options
|
|
14
14
|
from render_utils.utils_message_lua import UtilsMessageLua
|
|
15
15
|
from render_utils.validate_lua import ValidateLua
|
|
16
|
-
from
|
|
16
|
+
from bmcgo.codegen.lua.script.mdb_register import MdbRegister
|
|
17
17
|
from bmcgo.codegen.lua.script.base import Base
|
|
18
18
|
from bmcgo.codegen.lua.script.factory import Factory
|
|
19
19
|
|
|
@@ -24,3 +24,4 @@ class MessageUtils(Base, ValidateLua, UtilsMessageLua, MdbRegister):
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
Factory().register("message.lua.mako", MessageUtils)
|
|
27
|
+
Factory().register("v1/templates/apps/message.lua.mako", MessageUtils)
|
|
@@ -15,7 +15,7 @@ import re
|
|
|
15
15
|
from utils import Utils
|
|
16
16
|
from dto.options import Options
|
|
17
17
|
from render_utils.validate_lua import ValidateLua
|
|
18
|
-
from
|
|
18
|
+
from bmcgo.codegen.lua.script.mdb_register import MdbRegister
|
|
19
19
|
from bmcgo.codegen.lua.script.base import Base
|
|
20
20
|
from bmcgo.codegen.lua.script.factory import Factory
|
|
21
21
|
|
|
@@ -267,7 +267,9 @@ class Utils:
|
|
|
267
267
|
|
|
268
268
|
@staticmethod
|
|
269
269
|
def force_to_colon(path):
|
|
270
|
-
|
|
270
|
+
if isinstance(path, str):
|
|
271
|
+
return path.replace("${", ":").replace("}", "")
|
|
272
|
+
return [p.replace("${", ":").replace("}", "") for p in path]
|
|
271
273
|
|
|
272
274
|
@staticmethod
|
|
273
275
|
def check_db_open(name):
|
|
@@ -664,8 +666,15 @@ class Utils:
|
|
|
664
666
|
|
|
665
667
|
def get_path_params(self, path):
|
|
666
668
|
path = self.force_to_colon(path)
|
|
667
|
-
|
|
668
|
-
|
|
669
|
+
|
|
670
|
+
pattern = r':([a-zA-Z_][0-9a-zA-Z_]+)'
|
|
671
|
+
if isinstance(path, str):
|
|
672
|
+
params = re.compile(pattern).findall(path)
|
|
673
|
+
else:
|
|
674
|
+
params = []
|
|
675
|
+
for p in path:
|
|
676
|
+
params.extend(re.compile(pattern).findall(p))
|
|
677
|
+
|
|
669
678
|
return self.remove_duplicate(params)
|
|
670
679
|
|
|
671
680
|
def deduplicate_path(self, path):
|
|
@@ -3,6 +3,7 @@ TEMPLATE_BIN = ${SCRIPT_DIR}/template.py
|
|
|
3
3
|
SEP_IPMI_MESSAGE_CMDS_BIN = ${SCRIPT_DIR}/sep_ipmi_message_cmds.py
|
|
4
4
|
LUA_FORMATER = ${SCRIPT_DIR}/lua_format.py
|
|
5
5
|
MDB_INTF_DIR = ${TEMP_DIR}/opt/bmc/apps/mdb_interface/
|
|
6
|
+
LATEST_MDB_INTF_DIR = ${TEMP_DIR}/opt/bmc/apps/latest_mdb_interface/
|
|
6
7
|
YAML_TO_JSON_BIN = ${SCRIPT_DIR}/yaml_to_json.py
|
|
7
8
|
BAK_LOCAL_DB_DIR = ${GEN_BAK_DIR}/${PROJECT_NAME}
|
|
8
9
|
MAJOR_VERSION_EQ_1 := $(shell [ $(MAJOR_VERSION) -eq 1 ] && echo true)
|
|
@@ -63,9 +64,15 @@ $(strip $(subst .proto.json,,$(1)))
|
|
|
63
64
|
endef
|
|
64
65
|
|
|
65
66
|
define MAKE_MESSAGE
|
|
67
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
68
|
+
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} ${MAJOR_VERIONS_DIR}/v1/templates/apps/message.lua.mako utils/message.mako utils/enum.mako
|
|
69
|
+
@mkdir -p $$(dir $$@)
|
|
70
|
+
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako -o $$@
|
|
71
|
+
else
|
|
66
72
|
$$(GEN_OUT_DIR)/$(1).lua: ${PROTO_OUT_DIR}/$(1).proto.json $${TEMPLATE_BIN} message.lua.mako utils/message.mako utils/enum.mako
|
|
67
73
|
@mkdir -p $$(dir $$@)
|
|
68
74
|
python3 $${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR} -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/$(1).proto.json -f ${LUA_FORMATER} -t message.lua.mako -o $$@
|
|
75
|
+
endif
|
|
69
76
|
endef
|
|
70
77
|
$(foreach v, $(MESSAGE_FILES), $(eval $(call MAKE_MESSAGE,$(v))))
|
|
71
78
|
message: $(foreach v, $(MESSAGE_FILES), $(GEN_OUT_DIR)/$(v).lua)
|
|
@@ -131,6 +138,13 @@ endif
|
|
|
131
138
|
${PROTO_OUT_DIR}/_model.json: ${SCRIPT_DIR}/merge_model.py
|
|
132
139
|
python3 ${SCRIPT_DIR}/merge_model.py -i ${MDS_DIR}/model.json -o $@ -d ${MDB_INTF_DIR} -c ${SCRIPT_DIR}/../temp/check_cmd.json
|
|
133
140
|
|
|
141
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
142
|
+
model_consistency_check: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/model_consistency_check.py
|
|
143
|
+
python3 ${SCRIPT_DIR}/model_consistency_check.py -i ${PROTO_OUT_DIR}/_model.json -d ${LATEST_MDB_INTF_DIR}
|
|
144
|
+
else
|
|
145
|
+
model_consistency_check:
|
|
146
|
+
endif
|
|
147
|
+
|
|
134
148
|
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
135
149
|
$(MDS_DIR)/modelx.json: ${PROTO_OUT_DIR}/_model.json
|
|
136
150
|
mkdir -p $(@D)
|
|
@@ -164,11 +178,19 @@ ${MDS_DIR}/schema.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_schema.py
|
|
|
164
178
|
python3 ${SCRIPT_DIR}/gen_schema.py -i ${PROTO_OUT_DIR}/_model.json -n ${PROJECT_NAME} -o $@
|
|
165
179
|
endif
|
|
166
180
|
|
|
181
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
182
|
+
${PROTO_OUT_DIR}/db_json.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_db_json.py
|
|
183
|
+
python3 ${SCRIPT_DIR}/gen_historical_local_db_json.py -i ${BAK_LOCAL_DB_DIR}/local_db.lua -o ${PROTO_OUT_DIR}/historical_local_db.json
|
|
184
|
+
python3 ${SCRIPT_DIR}/gen_db_json.py -i ${PROTO_OUT_DIR}/_model.json -m ${PROTO_OUT_DIR}/historical_local_db.json -o $@
|
|
185
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/db_json.json -f ${LUA_FORMATER} -t v1/templates/apps/db.lua.mako -o ${GEN_OUT_DIR}/db.lua
|
|
186
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/local_db_json.json -f ${LUA_FORMATER} -t v1/templates/apps/local_db.lua.mako -o ${GEN_OUT_DIR}/local_db.lua
|
|
187
|
+
else
|
|
167
188
|
${PROTO_OUT_DIR}/db_json.json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_db_json.py
|
|
168
189
|
python3 ${SCRIPT_DIR}/gen_historical_local_db_json.py -i ${BAK_LOCAL_DB_DIR}/local_db.lua -o ${PROTO_OUT_DIR}/historical_local_db.json
|
|
169
190
|
python3 ${SCRIPT_DIR}/gen_db_json.py -i ${PROTO_OUT_DIR}/_model.json -m ${PROTO_OUT_DIR}/historical_local_db.json -o $@
|
|
170
191
|
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/db_json.json -f ${LUA_FORMATER} -t db.lua.mako -o ${GEN_OUT_DIR}/db.lua
|
|
171
192
|
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/ -n ${PROJECT_NAME} -i ${PROTO_OUT_DIR}/local_db_json.json -f ${LUA_FORMATER} -t local_db.lua.mako -o ${GEN_OUT_DIR}/local_db.lua
|
|
193
|
+
endif
|
|
172
194
|
|
|
173
195
|
ifneq ($(wildcard ${MDS_DIR}/types.json),)
|
|
174
196
|
# types代码生成
|
|
@@ -176,10 +198,17 @@ types_message_json: ${TYPES_JSON_PATH} ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
|
176
198
|
mkdir -p ${PROTO_OUT_DIR}/model_types/
|
|
177
199
|
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${TYPES_JSON_PATH} -o ${PROTO_OUT_DIR}/model_types/ -d ${MDB_INTF_DIR} -t
|
|
178
200
|
|
|
201
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
202
|
+
types_message: types_message_json
|
|
203
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
204
|
+
-i ${PROTO_OUT_DIR}/model_types/def_types.proto.json -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako \
|
|
205
|
+
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/types.lua);
|
|
206
|
+
else
|
|
179
207
|
types_message: types_message_json
|
|
180
208
|
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
181
209
|
-i ${PROTO_OUT_DIR}/model_types/def_types.proto.json -f ${LUA_FORMATER} -t message.lua.mako \
|
|
182
210
|
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/types.lua);
|
|
211
|
+
endif
|
|
183
212
|
|
|
184
213
|
endif
|
|
185
214
|
|
|
@@ -188,17 +217,36 @@ model_message_json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_rpc_msg_json.
|
|
|
188
217
|
mkdir -p ${PROTO_OUT_DIR}/model_types/
|
|
189
218
|
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${PROTO_OUT_DIR}/_model.json -o ${PROTO_OUT_DIR}/model_types/ -d ${MDB_INTF_DIR} -p
|
|
190
219
|
|
|
220
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
221
|
+
model_message: model_message_json
|
|
222
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/model_types/ -I def_types.proto.json), \
|
|
223
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
224
|
+
-i ${PROTO_OUT_DIR}/model_types/$x -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako \
|
|
225
|
+
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/$x);)
|
|
226
|
+
else
|
|
191
227
|
model_message: model_message_json
|
|
192
228
|
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/model_types/ -I def_types.proto.json), \
|
|
193
229
|
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/model_types/ -n ${PROJECT_NAME} \
|
|
194
230
|
-i ${PROTO_OUT_DIR}/model_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
195
231
|
-o $(call proto_json_to_lua, ${GENERATE_OUT_DIR}/class/types/$x);)
|
|
232
|
+
endif
|
|
196
233
|
|
|
197
234
|
# 服务端代码生成
|
|
198
235
|
service_message_json: ${PROTO_OUT_DIR}/_model.json ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
199
236
|
@mkdir -p ${PROTO_OUT_DIR}/json_types/
|
|
200
237
|
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${PROTO_OUT_DIR}/_model.json -o ${PROTO_OUT_DIR}/json_types/ -d ${MDB_INTF_DIR} -n ${PROJECT_NAME} -m
|
|
201
238
|
|
|
239
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
240
|
+
service_message: service_message_json
|
|
241
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
242
|
+
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
243
|
+
-i ${PROTO_OUT_DIR}/json_types/$x -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako \
|
|
244
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);)
|
|
245
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/device_types/),\
|
|
246
|
+
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/device_types/ -n ${PROJECT_NAME} \
|
|
247
|
+
-i ${PROTO_OUT_DIR}/device_types/$x -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako \
|
|
248
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/device_types/$x);)
|
|
249
|
+
else
|
|
202
250
|
service_message: service_message_json
|
|
203
251
|
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
204
252
|
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
@@ -208,6 +256,7 @@ service_message: service_message_json
|
|
|
208
256
|
python3 ${TEMPLATE_BIN} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/device_types/ -n ${PROJECT_NAME} \
|
|
209
257
|
-i ${PROTO_OUT_DIR}/device_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
210
258
|
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/device_types/$x);)
|
|
259
|
+
endif
|
|
211
260
|
|
|
212
261
|
schema: ${MDS_DIR}/schema.json
|
|
213
262
|
database: ${PROTO_OUT_DIR}/db_json.json
|
|
@@ -275,11 +324,19 @@ client_messages_json: ${MDS_DIR}/service.json ${SCRIPT_DIR}/gen_rpc_msg_json.py
|
|
|
275
324
|
@mkdir -p ${PROTO_OUT_DIR}/json_types/
|
|
276
325
|
python3 ${SCRIPT_DIR}/gen_rpc_msg_json.py -i ${MDS_DIR}/service.json -o ${PROTO_OUT_DIR}/json_types/ -d ${MDB_INTF_DIR} -n ${PROJECT_NAME} -x
|
|
277
326
|
|
|
327
|
+
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
328
|
+
client_messages: client_messages_json
|
|
329
|
+
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
330
|
+
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
331
|
+
-i ${PROTO_OUT_DIR}/json_types/$x -f ${LUA_FORMATER} -t v1/templates/apps/message.lua.mako \
|
|
332
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);)
|
|
333
|
+
else
|
|
278
334
|
client_messages: client_messages_json
|
|
279
335
|
@$(foreach x,$(shell ls $(PROTO_OUT_DIR)/json_types/),\
|
|
280
336
|
python3 ${TEMPLATE_BIN} -v ${VERSION} -d ${PROTO_DIR} -j ${PROTO_OUT_DIR}/json_types/ -n ${PROJECT_NAME} \
|
|
281
337
|
-i ${PROTO_OUT_DIR}/json_types/$x -f ${LUA_FORMATER} -t message.lua.mako \
|
|
282
|
-
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);)
|
|
338
|
+
-o $(call proto_json_to_lua, ${GEN_OUT_DIR}/json_types/$x);)
|
|
339
|
+
endif
|
|
283
340
|
|
|
284
341
|
ifeq ($(MAJOR_VERSION_EQ_1), true)
|
|
285
342
|
${GEN_OUT_DIR}/client.lua : ${PROTO_OUT_DIR}/client.json ${TEMPLATE_BIN} \
|
|
@@ -295,4 +352,4 @@ client: ${GEN_OUT_DIR}/client.lua
|
|
|
295
352
|
|
|
296
353
|
endif
|
|
297
354
|
|
|
298
|
-
all: client service modelx message datas datas_conf restapi restapi_resource schema model types_message model_message database ipmi orm_classes feature impl_feature
|
|
355
|
+
all: client service modelx message datas datas_conf restapi restapi_resource schema model types_message model_message database ipmi orm_classes feature impl_feature model_consistency_check
|
|
@@ -0,0 +1,108 @@
|
|
|
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 bmcgo.codegen.lua.script.dto.options import Options
|
|
15
|
+
from bmcgo.codegen.lua.script.mdb_register import MdbRegister
|
|
16
|
+
from bmcgo.codegen.lua.script.base import Base
|
|
17
|
+
from bmcgo.codegen.lua.script.factory import Factory
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ConsistencyClientLuaUtils(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_path_namespace_name(self, index):
|
|
75
|
+
return f"path_namespace{index + 1}"
|
|
76
|
+
|
|
77
|
+
def get_path_namespace_list(self, paths):
|
|
78
|
+
indexed_path_namespace = [
|
|
79
|
+
f"path_namespace{index + 1}"
|
|
80
|
+
for index, _ in enumerate(paths)
|
|
81
|
+
]
|
|
82
|
+
return "{" + ", ".join(indexed_path_namespace) + "}"
|
|
83
|
+
|
|
84
|
+
def get_dep_properties(self, properties):
|
|
85
|
+
if properties == ["*"]:
|
|
86
|
+
return ""
|
|
87
|
+
|
|
88
|
+
return ', {"' + '", "'.join(properties) + '"}'
|
|
89
|
+
|
|
90
|
+
def get_path_namespace(self, path):
|
|
91
|
+
if not self.get_path_params(path):
|
|
92
|
+
return f"'{path}'"
|
|
93
|
+
path_with_params = self.make_path_with_params(path)
|
|
94
|
+
if Utils.get_lua_codegen_version() >= 17:
|
|
95
|
+
return f"path_params and ({path_with_params}) or '{path}'"
|
|
96
|
+
prefix = path_with_params.split("/' ..")[0]
|
|
97
|
+
return f"path_params and ({path_with_params}) or {prefix}'"
|
|
98
|
+
|
|
99
|
+
def get_path_patterns(self, paths):
|
|
100
|
+
return MdbRegister.convert_to_lua(self, paths)
|
|
101
|
+
|
|
102
|
+
def get_object_path(self, path):
|
|
103
|
+
if not self.get_path_params(path):
|
|
104
|
+
return f"'{path}'"
|
|
105
|
+
path_with_params = self.make_path_with_params(path)
|
|
106
|
+
return f"path_params and ({path_with_params}) or '{path}'"
|
|
107
|
+
|
|
108
|
+
Factory().register("v1/templates/apps/client.lua.mako", ConsistencyClientLuaUtils)
|