mwgencode 1.4.1__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.
- gencode/__init__.py +140 -0
- gencode/dd_models.py +256 -0
- gencode/ext.py +19 -0
- gencode/gen_code.py +343 -0
- gencode/gencode/__init__.py +0 -0
- gencode/gencode/export_class2swgclass.py +206 -0
- gencode/gencode/gen_bo_models_code.py +719 -0
- gencode/gencode/gen_state_code.py +171 -0
- gencode/gencode/gen_swagger_code.py +94 -0
- gencode/gencode/gen_tests_code.py +113 -0
- gencode/gencode/sample/__init__.py +2 -0
- gencode/gencode/sample/babel.cfg +3 -0
- gencode/gencode/sample/config-sample.ini +9 -0
- gencode/gencode/sample/config.ini +14 -0
- gencode/gencode/sample/create_new_table_run.pys +19 -0
- gencode/gencode/sample/dockerignore.dock +57 -0
- gencode/gencode/sample/file_utils.pys +396 -0
- gencode/gencode/sample/gencode.xmi +33 -0
- gencode/gencode/sample/gitignore.git +14 -0
- gencode/gencode/sample/migrate_run.bat +5 -0
- gencode/gencode/sample/migrate_run.pys +9 -0
- gencode/gencode/sample/requirements.txt +17 -0
- gencode/gencode/sample/run.sh +27 -0
- gencode/gencode/sample/seeds/__init__.py +0 -0
- gencode/gencode/sample/seeds/models_rm.pys +187 -0
- gencode/gencode/sample/seeds/seed_dev_data.pys +21 -0
- gencode/gencode/sample/seeds/seed_init.pys +17 -0
- gencode/gencode/sample/seeds/seed_rm.pys +39 -0
- gencode/gencode/sample/seeds/seed_run.pys +13 -0
- gencode/gencode/sample/seeds/seed_utils.pys +23 -0
- gencode/gencode/sample/test__init__.pys +6 -0
- gencode/gencode/sample/test_run.pys +4 -0
- gencode/gencode/sample/utils.pys +92 -0
- gencode/gencode/template/Dockerfile.tmp +55 -0
- gencode/gencode/template/README.md +91 -0
- gencode/gencode/template/__init__.py +0 -0
- gencode/gencode/template/__init__.pys +99 -0
- gencode/gencode/template/config.pys +134 -0
- gencode/gencode/template/default.conf +21 -0
- gencode/gencode/template/docker-compose-dev.yaml +52 -0
- gencode/gencode/template/docker-compose.yaml +55 -0
- gencode/gencode/template/drone.tmp +45 -0
- gencode/gencode/template/flask_models.pys +107 -0
- gencode/gencode/template/flask_models_base.pys +159 -0
- gencode/gencode/template/gen_code_flask.yaml +21 -0
- gencode/gencode/template/gen_code_run.pys +28 -0
- gencode/gencode/template/k8s-tmp.yml +141 -0
- gencode/gencode/template/run.pys +52 -0
- gencode/gencode/template/sample.mdj +1193 -0
- gencode/gencode/template/setup.tmp +48 -0
- gencode/gencode/template/supervisord.conf +21 -0
- gencode/gencode/template/swagger_file.yaml +195 -0
- gencode/gencode/template/swg_class.tmp +41 -0
- gencode/gencode/template/swg_ctrl_code.pys +130 -0
- gencode/gencode/template/swg_package_mng.tmp +4423 -0
- gencode/gencode/template/test_test_base.tmp +34 -0
- gencode/gencode/template/tests/__init__.py +0 -0
- gencode/gencode/template/tests/__init__.pys +5 -0
- gencode/gencode/template/tests/init_test_data.pys +80 -0
- gencode/gencode/template/tests/run.pys +4 -0
- gencode/gencode/template/tests/test_base.pys +87 -0
- gencode/gencode/template/tests/test_classmng.pys +58 -0
- gencode/gencode/template/uwsgi.ini +20 -0
- gencode/gencode/template/uwsgi_run.pys +44 -0
- gencode/importmdj/__init__.py +0 -0
- gencode/importmdj/import_dd_classes.py +369 -0
- gencode/importmdj/import_swagger2_class.py +371 -0
- gencode/importmdj/import_uml_models.py +466 -0
- gencode/importxmi/__init__.py +1 -0
- gencode/importxmi/import_classes.py +342 -0
- gencode/importxmi/import_sequences.py +291 -0
- gencode/importxmi/import_states.py +150 -0
- gencode/importxmi/import_swagger.py +151 -0
- gencode/swg2_class_models.py +179 -0
- gencode/uml_class_models.py +295 -0
- gencode/upgrade.py +113 -0
- gencode/utils.py +225 -0
- manage.py +194 -0
- mwgencode-1.4.1.dist-info/METADATA +325 -0
- mwgencode-1.4.1.dist-info/RECORD +84 -0
- mwgencode-1.4.1.dist-info/WHEEL +5 -0
- mwgencode-1.4.1.dist-info/entry_points.txt +2 -0
- mwgencode-1.4.1.dist-info/licenses/LICENSE.txt +19 -0
- mwgencode-1.4.1.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
try: # 导入模块
|
|
2
|
+
import xml.etree.cElementTree as ET
|
|
3
|
+
except ImportError:
|
|
4
|
+
import xml.etree.ElementTree as ET
|
|
5
|
+
|
|
6
|
+
from gencode import (ImportBase,uml,xmi,_id,_type,_extension
|
|
7
|
+
)
|
|
8
|
+
from gencode.swg2_class_models import *
|
|
9
|
+
from gencode.importmdj.import_uml_models import *
|
|
10
|
+
from gencode.ext import Session
|
|
11
|
+
|
|
12
|
+
required = lambda st: ('noreq' not in st) and ('nr' not in st)
|
|
13
|
+
|
|
14
|
+
class ImportSwagger(ImportBase):
|
|
15
|
+
def __init__(self):
|
|
16
|
+
self.swagger = None
|
|
17
|
+
self.session = Session()
|
|
18
|
+
self.project = None
|
|
19
|
+
|
|
20
|
+
def __handle_swagger(self):
|
|
21
|
+
# 记录swagger package 信息
|
|
22
|
+
pkg_swg = self.session.query(Package).\
|
|
23
|
+
filter(Package.name=='swagger').\
|
|
24
|
+
filter(Package.projectid==self.project.id).first()
|
|
25
|
+
if not pkg_swg:
|
|
26
|
+
raise Exception('the project have no swagger package。')
|
|
27
|
+
self.swagger = self.session.query(Swagger2).filter(Swagger2.id==pkg_swg.id).first()
|
|
28
|
+
# 不需要重复创建 swagger
|
|
29
|
+
if self.swagger:
|
|
30
|
+
return self.swagger
|
|
31
|
+
self.swagger = Swagger2()
|
|
32
|
+
try:
|
|
33
|
+
self.swagger.name,self.swagger.version ,*ext_sp= pkg_swg.stereotype.split('/')
|
|
34
|
+
self.swagger.auth =ext_sp[0] if ext_sp else 'jwt'
|
|
35
|
+
except Exception as e:
|
|
36
|
+
raise Exception('the swagger stereotype define error,sample:"service_name/v1.0",error:%s'%e)
|
|
37
|
+
self.swagger.resp_xml = 'xml' in ext_sp
|
|
38
|
+
self.swagger.resp_html = 'html' in ext_sp
|
|
39
|
+
self.swagger.doc = pkg_swg.doc.replace('---','\n').replace('"','\'')
|
|
40
|
+
self.swagger.id = pkg_swg.id
|
|
41
|
+
self.session.add(self.swagger)
|
|
42
|
+
self.session.commit()
|
|
43
|
+
self.__handle_tags(pkg_swg.packages)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# pkgs = pkg_swg.findall('packagedElement')
|
|
47
|
+
|
|
48
|
+
def __get_sw_type_format(self, type):
|
|
49
|
+
type = type.lower()
|
|
50
|
+
if type.startswith('string') and len(type)>len('string'):
|
|
51
|
+
type = 'string'
|
|
52
|
+
if type == 'integer':
|
|
53
|
+
return 'integer', 'int32'
|
|
54
|
+
elif type == 'long':
|
|
55
|
+
return 'integer', 'int64'
|
|
56
|
+
elif type == 'float':
|
|
57
|
+
return 'number', 'float'
|
|
58
|
+
elif type == 'double':
|
|
59
|
+
return 'number', 'double'
|
|
60
|
+
elif type in ('string','text') :
|
|
61
|
+
return 'string', ''
|
|
62
|
+
elif type == 'byte':
|
|
63
|
+
return 'string', 'byte'
|
|
64
|
+
elif type == 'binary':
|
|
65
|
+
return 'string', 'binary'
|
|
66
|
+
elif type == 'boolean':
|
|
67
|
+
return 'boolean', ''
|
|
68
|
+
elif type == 'date':
|
|
69
|
+
return 'string', 'date'
|
|
70
|
+
elif type in ('datetime', 'tdatetime','time','ttime'):
|
|
71
|
+
return 'string', 'date-time'
|
|
72
|
+
elif type == 'password':
|
|
73
|
+
return 'string', 'password'
|
|
74
|
+
elif type == 'file':
|
|
75
|
+
return 'file', ''
|
|
76
|
+
elif type == '':
|
|
77
|
+
return 'string',''
|
|
78
|
+
else:
|
|
79
|
+
return type, ''
|
|
80
|
+
|
|
81
|
+
def __get_in(self,st):
|
|
82
|
+
'q:query,f:formdata,b:body,h:header,p:path,nr:not Request'
|
|
83
|
+
if ('query' in st) or ('q' in st):
|
|
84
|
+
return 'query'
|
|
85
|
+
elif ('formdata' in st) or ('fd' in st) or ('f' in st):
|
|
86
|
+
return 'formData'
|
|
87
|
+
elif ('body' in st) or ('b' in st) or ('bd' in st):
|
|
88
|
+
return 'body'
|
|
89
|
+
elif ('header' in st) or ('h' in st) or ('hd' in st):
|
|
90
|
+
return 'header'
|
|
91
|
+
elif ('path' in st) or ('p' in st) or ('pth' in st):
|
|
92
|
+
return 'path'
|
|
93
|
+
# elif 'file' in st:
|
|
94
|
+
# return 'file'
|
|
95
|
+
return ''
|
|
96
|
+
|
|
97
|
+
def __get_respcode(self, action, code):
|
|
98
|
+
if code in ('default','result','return'):
|
|
99
|
+
if action in ['post', 'put']:
|
|
100
|
+
return '201'
|
|
101
|
+
elif action == 'delete':
|
|
102
|
+
return '204'
|
|
103
|
+
else:
|
|
104
|
+
return '200'
|
|
105
|
+
else:
|
|
106
|
+
return code
|
|
107
|
+
|
|
108
|
+
def __handle_tags(self,pkgs):
|
|
109
|
+
for pkg in pkgs:
|
|
110
|
+
tag = Tag2()
|
|
111
|
+
tag.id = pkg.id
|
|
112
|
+
tag.doc = pkg.doc.replace('---','\n').replace('"','\'')
|
|
113
|
+
tag.name =pkg.name.lower()
|
|
114
|
+
tag.swaggerid = self.swagger.id
|
|
115
|
+
tag.swagger = self.swagger
|
|
116
|
+
self.session.add(tag)
|
|
117
|
+
self.session.commit()
|
|
118
|
+
for cls in pkg.classs:
|
|
119
|
+
if cls.type != Class_uml.umlsignal.value:
|
|
120
|
+
continue
|
|
121
|
+
self.__handle_action(tag, cls.operations)
|
|
122
|
+
|
|
123
|
+
def __get_path(self,tag,op_name):
|
|
124
|
+
path = self.session.query(Path2).filter(Path2.name==op_name).\
|
|
125
|
+
filter(Path2.tagid==tag.id).first()
|
|
126
|
+
if not path:
|
|
127
|
+
path = Path2()
|
|
128
|
+
path.name = op_name.lower()
|
|
129
|
+
path.tagid = tag.id
|
|
130
|
+
path.tag = tag
|
|
131
|
+
self.session.add(path)
|
|
132
|
+
self.session.commit()
|
|
133
|
+
return path
|
|
134
|
+
|
|
135
|
+
def copy_lk_path(self, act):
|
|
136
|
+
path_n = Path2(**act.path.to_json())
|
|
137
|
+
path_n.id = None
|
|
138
|
+
path_n.is_lk = True
|
|
139
|
+
path_n.name = path_n.name + '_lk'
|
|
140
|
+
path_n.tagid = act.path.tagid
|
|
141
|
+
self.session.add(path_n)
|
|
142
|
+
self.session.commit()
|
|
143
|
+
|
|
144
|
+
act_n = Action2(**act.to_json())
|
|
145
|
+
act_n.id = act_n.id+'_lk'
|
|
146
|
+
act_n.is_lk = True
|
|
147
|
+
|
|
148
|
+
act_n.pathid = path_n.id
|
|
149
|
+
self.session.add(act_n)
|
|
150
|
+
for param in act.params:
|
|
151
|
+
param_js = param.to_json()
|
|
152
|
+
param_js.pop('id')
|
|
153
|
+
param_n = Param2(**param_js)
|
|
154
|
+
# param_n.id = param_n.id+'_lk'
|
|
155
|
+
param_n.actionid = act_n.id
|
|
156
|
+
self.session.add(param_n)
|
|
157
|
+
for resp in act.resps:
|
|
158
|
+
resp_js = resp.to_json()
|
|
159
|
+
resp_js.pop('id')
|
|
160
|
+
resp_n =Resp2(**resp_js)
|
|
161
|
+
# resp_n.id = resp_n.id+'_lk'
|
|
162
|
+
resp_n.actionid = act_n.id
|
|
163
|
+
self.session.add(resp_n)
|
|
164
|
+
self.session.commit()
|
|
165
|
+
|
|
166
|
+
def __handle_action(self, tag, ops):
|
|
167
|
+
# print('tag:%s'%tag)
|
|
168
|
+
for op in ops:
|
|
169
|
+
st = op.stereotype.split('/')
|
|
170
|
+
path = self.__get_path(tag,op.name.lower())
|
|
171
|
+
logging.debug('%s:%s'%(tag,op.name))
|
|
172
|
+
action = Action2()
|
|
173
|
+
action.id = op.id
|
|
174
|
+
action.summary, *action.doc = op.doc.split('---',1)
|
|
175
|
+
action.ver_str = path.tag.swagger.version.replace('.', '_')
|
|
176
|
+
action.doc = ''.join(action.doc).strip().replace('"','\'')
|
|
177
|
+
action.has_formdata = False
|
|
178
|
+
# 记录action有包含lk,需要做进一步处理
|
|
179
|
+
action.include_lk = 'lk' in st
|
|
180
|
+
if action.include_lk:
|
|
181
|
+
st.remove('lk')
|
|
182
|
+
# ks:key auth,js:jwt auth ,bs :basc auth ,s:jw auth,os:oauth2
|
|
183
|
+
action.is_auth = 'ks' in st or 'js' in st or 'bs' in st or 'os' in st or 's' in st
|
|
184
|
+
if action.is_auth:
|
|
185
|
+
if 'ks' in st:
|
|
186
|
+
action.auth_type='ks'
|
|
187
|
+
st.remove('ks')
|
|
188
|
+
elif 'js' in st:
|
|
189
|
+
action.auth_type = 'js'
|
|
190
|
+
st.remove('js')
|
|
191
|
+
elif 'bs' in st:
|
|
192
|
+
action.auth_type = 'bs'
|
|
193
|
+
st.remove('bs')
|
|
194
|
+
elif 'os' in st:
|
|
195
|
+
action.auth_type = 'os'
|
|
196
|
+
st.remove('os')
|
|
197
|
+
elif 's' in st:
|
|
198
|
+
action.auth_type = 's'
|
|
199
|
+
st.remove('s')
|
|
200
|
+
action.action = st[0]
|
|
201
|
+
action.path =path
|
|
202
|
+
action.pathid = path.id
|
|
203
|
+
try:
|
|
204
|
+
action.in_param_name = op.in_param.name
|
|
205
|
+
action.return_param_name = op.return_param.name
|
|
206
|
+
except Exception as e:
|
|
207
|
+
logging.error(op,e)
|
|
208
|
+
raise
|
|
209
|
+
self.session.add_all([action,path])
|
|
210
|
+
self.session.commit()
|
|
211
|
+
self.__handle_param(action,op.in_param)
|
|
212
|
+
self.__handle_resp(action,op.return_param)
|
|
213
|
+
if action.include_lk:
|
|
214
|
+
self.copy_lk_path(action)
|
|
215
|
+
|
|
216
|
+
def __handle_param(self,act,in_param):
|
|
217
|
+
assert in_param.object_type, 'in type 必须是object,请确认[%s.%s]名称是否有误' % (act.call_path(),in_param.name)
|
|
218
|
+
assert in_param.object_type.type == Class_uml.umlprimitivetype.value, 'in type [%s.%s]必须是PrimitiveType' %(act.call_path(),in_param.object_type.name)
|
|
219
|
+
for proper in in_param.object_type.propertys:
|
|
220
|
+
if not proper.type :
|
|
221
|
+
raise Exception('[%s %s.%s]参数必须指定类型' % (act.call_path(),in_param.object_type.name, proper.name))
|
|
222
|
+
st = proper.stereotype.split('/')
|
|
223
|
+
|
|
224
|
+
param = Param2()
|
|
225
|
+
# param.id = proper.id
|
|
226
|
+
# 对接他方api时,会有大小写的问题
|
|
227
|
+
param.name = proper.name #.lower()
|
|
228
|
+
param.in_ = self.__get_in(st)
|
|
229
|
+
if not param.in_:
|
|
230
|
+
raise Exception('{tag}.<<{act}>>{path}.inparam.<<{pst}>>{pname}的stereotype缺少或不支持,'
|
|
231
|
+
'合法的st如下:\n '
|
|
232
|
+
'q -> query \n'
|
|
233
|
+
'f ->formData \n '
|
|
234
|
+
'b ->body \n '
|
|
235
|
+
'h -> header \n '
|
|
236
|
+
'p -> path \n'
|
|
237
|
+
'nr -> required = False'.format(
|
|
238
|
+
tag=act.path.tag.name,act=act.action,
|
|
239
|
+
path=act.path.name,pname=proper.name,pst=proper.stereotype
|
|
240
|
+
))
|
|
241
|
+
param.is_body = param.in_=='body'
|
|
242
|
+
param.is_formdata = param.in_=='formData'
|
|
243
|
+
param.is_header = param.in_=='header'
|
|
244
|
+
param.is_path = param.in_=='path'
|
|
245
|
+
param.is_query = param.in_=='query'
|
|
246
|
+
if param.in_=='formData':
|
|
247
|
+
act.has_formdata = True
|
|
248
|
+
if proper.name=='page':
|
|
249
|
+
act.has_page = True
|
|
250
|
+
# self.session.add(act)
|
|
251
|
+
# self.session.commit()
|
|
252
|
+
param.desc = proper.doc.replace('---','\n').replace('"','\'')
|
|
253
|
+
param.type,param.format = self.__get_sw_type_format(proper.type)
|
|
254
|
+
param.type_attr = 'object' if proper.objectid else 'data'
|
|
255
|
+
param.is_array = len(proper.multiplicity)>0
|
|
256
|
+
param.required = required(st)
|
|
257
|
+
param.actionid = act
|
|
258
|
+
param.actionid = act.id
|
|
259
|
+
if param.type_attr == 'object':
|
|
260
|
+
if proper.object is None:
|
|
261
|
+
logging.error('error: %s.%s的属性【%s】 没有指定类型'%(act.call_path(),in_param.object_type.name,proper.name))
|
|
262
|
+
exit(-1)
|
|
263
|
+
if proper.object.type not in (Class_uml.umldatatype.value, Class_uml.umlclass.value):
|
|
264
|
+
raise Exception('%s.%s.%s 回应物件类型只能是%s和%s,不能是:%s' % (
|
|
265
|
+
act.call_path(),in_param.object_type.name,proper.name,Class_uml.umldatatype.value, Class_uml.umlclass.value, proper.object.type))
|
|
266
|
+
param.ref_name = proper.object.name.lower()
|
|
267
|
+
self.__set_defines(act.path.tag.swagger, proper.object)
|
|
268
|
+
else:
|
|
269
|
+
if param.in_ == 'body':
|
|
270
|
+
raise Exception('%s,普通数据类型不能是body,object:%s,attr:%s' % (
|
|
271
|
+
act.call_path(),in_param.object_type.name, proper.name))
|
|
272
|
+
self.session.add_all([param,act])
|
|
273
|
+
self.session.commit()
|
|
274
|
+
|
|
275
|
+
def __handle_resp(self,act,return_param):
|
|
276
|
+
logger.debug('%s'%act)
|
|
277
|
+
assert return_param.object_type, '[%s]return type 必须是object,请确认return名称是否有误'%(act.call_path())
|
|
278
|
+
assert return_param.object_type.type == Class_uml.umlprimitivetype.value, '%s.return type(%s)必须是PrimitiveType' % (act.call_path(), return_param.object_type.name)
|
|
279
|
+
try:
|
|
280
|
+
for proper in return_param.object_type.propertys :
|
|
281
|
+
# print('%s,%s,%s,%s'%(act.path.name,return_param.name,return_param.object_type.name,proper.name))
|
|
282
|
+
# proper = Property()
|
|
283
|
+
if not proper.type:
|
|
284
|
+
if proper.name in ('return', 'result', 'default'):
|
|
285
|
+
proper.type = 'string'
|
|
286
|
+
else:
|
|
287
|
+
raise Exception('[%s %s.%s]参数必须指定类型' % (act.call_path(),return_param.object_type.name, proper.name))
|
|
288
|
+
resp = Resp2()
|
|
289
|
+
# resp.id = proper.id
|
|
290
|
+
resp.actionid = act.id
|
|
291
|
+
# resp.action = act
|
|
292
|
+
resp.type, resp.format = self.__get_sw_type_format(proper.type)
|
|
293
|
+
resp.type_attr = 'object' if proper.objectid else 'data'
|
|
294
|
+
resp.is_array = len(proper.multiplicity) > 0
|
|
295
|
+
if resp.type_attr == 'object':
|
|
296
|
+
resp.ref_name = proper.object.name.lower()
|
|
297
|
+
resp.umlcls_type = proper.object.type
|
|
298
|
+
if resp.umlcls_type not in (Class_uml.umldatatype.value,Class_uml.umlclass.value):
|
|
299
|
+
raise Exception('%s.%s 回应物件类型只能是%s和%s,不能是:%s'%(act.call_path(),return_param.object_type.name, Class_uml.umldatatype.value,Class_uml.umlclass.value,resp.umlcls_type))
|
|
300
|
+
self.__set_defines(act.path.tag.swagger, proper.object,act.is_lk)
|
|
301
|
+
resp.desc = proper.doc.replace('---','\n').replace('"','\'')
|
|
302
|
+
|
|
303
|
+
resp.code = self.__get_respcode(act.action, proper.name)
|
|
304
|
+
|
|
305
|
+
self.session.add(resp)
|
|
306
|
+
self.session.commit()
|
|
307
|
+
if proper.name in ('return','result','default'):
|
|
308
|
+
act.default_respid =resp.id
|
|
309
|
+
self.session.add(act)
|
|
310
|
+
self.session.commit()
|
|
311
|
+
|
|
312
|
+
except Exception as e:
|
|
313
|
+
raise Exception('%s.%s.%s.%s.%s raise error:%s'%(act.path.tag.name,
|
|
314
|
+
act.path.name,
|
|
315
|
+
return_param.name,
|
|
316
|
+
return_param.object_type.name,
|
|
317
|
+
proper.name,
|
|
318
|
+
e))
|
|
319
|
+
|
|
320
|
+
def __set_defines(self,swg,cls,is_lk=False):
|
|
321
|
+
defi = self.session.query(Define2).filter(Define2.id == cls.id).first()
|
|
322
|
+
if not defi:
|
|
323
|
+
defi =Define2()
|
|
324
|
+
defi.id = cls.id
|
|
325
|
+
defi.name = cls.name.lower()
|
|
326
|
+
defi.swaggerid=swg.id
|
|
327
|
+
defi.is_lk = is_lk
|
|
328
|
+
defi.swagger = swg
|
|
329
|
+
self.session.add(defi)
|
|
330
|
+
self.session.commit()
|
|
331
|
+
for proper in cls.propertys:
|
|
332
|
+
attr = Attr2()
|
|
333
|
+
# attr.id = proper.id
|
|
334
|
+
# attr.name = proper.name.lower()
|
|
335
|
+
attr.name = proper.name
|
|
336
|
+
attr.type, attr.format = self.__get_sw_type_format(proper.type)
|
|
337
|
+
attr.type_attr = 'object' if proper.objectid else 'data'
|
|
338
|
+
attr.defineid = defi.id
|
|
339
|
+
attr.is_array = len(proper.multiplicity)>0
|
|
340
|
+
attr.desc = proper.doc.replace('---','').replace('"','\'')
|
|
341
|
+
attr.define = defi
|
|
342
|
+
if attr.type_attr == 'object':
|
|
343
|
+
attr.ref_name = proper.object.name.lower()
|
|
344
|
+
self.__set_defines(swg, proper.object,is_lk)
|
|
345
|
+
self.session.add(attr)
|
|
346
|
+
self.session.commit()
|
|
347
|
+
|
|
348
|
+
return defi
|
|
349
|
+
|
|
350
|
+
def impUMLModels(self,file):
|
|
351
|
+
self.importer = Import_uml_models(file)
|
|
352
|
+
self.project = self.importer.import_model()
|
|
353
|
+
self.__handle_swagger()
|
|
354
|
+
return self.swagger
|
|
355
|
+
|
|
356
|
+
if __name__ == '__main__':
|
|
357
|
+
if __name__ == '__main__':
|
|
358
|
+
session = Session()
|
|
359
|
+
i = ImportSwagger()
|
|
360
|
+
i.impUMLModels(r"D:\mwwork\projects\gencode\docs\test3.mdj")
|
|
361
|
+
print('swagger:',session.query(Swagger2).all())
|
|
362
|
+
print('Path2:',session.query(Path2).all())
|
|
363
|
+
print('Action2:',session.query(Action2).all())
|
|
364
|
+
print('Param2:',session.query(Param2).all())
|
|
365
|
+
print('Resp2:',session.query(Resp2).all())
|
|
366
|
+
print('Define:', session.query(Define2).all())
|
|
367
|
+
print('Attr:',session.query(Attr2).all())
|
|
368
|
+
# attr = session.query(Attr2).first()
|
|
369
|
+
# attr1 = attr.copy()
|
|
370
|
+
# print(attr1)
|
|
371
|
+
|