@darabonba/python-generator 2.0.8 → 2.0.10
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.
- package/ChangeLog.md +3 -0
- package/lib/builtin.js +12 -3
- package/lib/generator.js +238 -239
- package/lib/helper.js +237 -5
- package/package.json +1 -1
- package/tests/expected/alias/setup.py +17 -13
- package/tests/expected/alias/tea_python_tests/client.py +6 -6
- package/tests/expected/annotation/tea_python_tests/client.py +4 -4
- package/tests/expected/annotation/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/annotation/tea_python_tests/models/_test.py +1 -1
- package/tests/expected/api/tea_python_tests/client.py +4 -4
- package/tests/expected/builtin/tea_python_tests/client.py +18 -16
- package/tests/expected/comment/tea_python_tests/client.py +6 -5
- package/tests/expected/comment/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/comment/tea_python_tests/models/_test_1.py +2 -1
- package/tests/expected/comment/tea_python_tests/models/_test_2.py +1 -1
- package/tests/expected/comment/tea_python_tests/models/_test_3.py +1 -1
- package/tests/expected/complex/tea_python_tests/client.py +17 -16
- package/tests/expected/complex/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/expected/complex/tea_python_tests/exceptions/_err_1.py +2 -1
- package/tests/expected/complex/tea_python_tests/exceptions/_err_2.py +1 -1
- package/tests/expected/complex/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/complex/tea_python_tests/models/_complex_request.py +7 -6
- package/tests/expected/complex/tea_python_tests/models/_response.py +2 -2
- package/tests/expected/const/tea_python_tests/client.py +0 -2
- package/tests/expected/empty/tea_python_tests/client.py +0 -2
- package/tests/expected/exec/tea_python_tests/exec_client.py +3 -2
- package/tests/expected/function/tea_python_tests/client.py +2 -1
- package/tests/expected/import/setup.py +4 -2
- package/tests/expected/import/tea_python_tests/client.py +4 -3
- package/tests/expected/map/tea_python_tests/client.py +3 -3
- package/tests/expected/model/tea_python_tests/client.py +0 -2
- package/tests/expected/model/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/expected/model/tea_python_tests/exceptions/_main_file.py +3 -2
- package/tests/expected/model/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/model/tea_python_tests/models/_class.py +1 -1
- package/tests/expected/model/tea_python_tests/models/_m.py +2 -2
- package/tests/expected/model/tea_python_tests/models/_main_file.py +2 -2
- package/tests/expected/model/tea_python_tests/models/_model.py +1 -1
- package/tests/expected/model/tea_python_tests/models/_my_model.py +13 -12
- package/tests/expected/modelConfig/tea_python_tests/client.py +0 -2
- package/tests/expected/modelConfig/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/expected/modelConfig/tea_python_tests/exceptions/_main_file.py +3 -2
- package/tests/expected/modelConfig/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/modelConfig/tea_python_tests/models/_class.py +1 -1
- package/tests/expected/modelConfig/tea_python_tests/models/_m.py +2 -2
- package/tests/expected/modelConfig/tea_python_tests/models/_main_file.py +2 -2
- package/tests/expected/modelConfig/tea_python_tests/models/_model.py +1 -1
- package/tests/expected/modelConfig/tea_python_tests/models/_my_model.py +13 -12
- package/tests/expected/multi/tea_python_tests/api.py +5 -5
- package/tests/expected/multi/tea_python_tests/api_models/__init__.py +0 -2
- package/tests/expected/multi/tea_python_tests/api_models/_test_model_dir_2.py +1 -1
- package/tests/expected/multi/tea_python_tests/client.py +4 -3
- package/tests/expected/multi/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/expected/multi/tea_python_tests/exceptions/_err.py +1 -1
- package/tests/expected/multi/tea_python_tests/lib/util.py +0 -1
- package/tests/expected/multi/tea_python_tests/model/user.py +3 -2
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/__init__.py +0 -2
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err.py +1 -1
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err_1.py +1 -1
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err_2.py +1 -1
- package/tests/expected/multi/tea_python_tests/model/user_models/__init__.py +0 -2
- package/tests/expected/multi/tea_python_tests/model/user_models/_base_info.py +1 -1
- package/tests/expected/multi/tea_python_tests/model/user_models/_info.py +1 -1
- package/tests/expected/multi/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/multi/tea_python_tests/models/_test_model_dir.py +3 -2
- package/tests/expected/statements/tea_python_tests/client.py +3 -3
- package/tests/expected/super/tea_python_tests/client.py +2 -2
- package/tests/expected/typedef/tea_python_tests/client.py +5 -5
- package/tests/expected/typedef/tea_python_tests/models/__init__.py +0 -2
- package/tests/expected/typedef/tea_python_tests/models/_m.py +3 -3
- package/tests/fixtures/alias/Darafile +5 -4
- package/tests/fixtures/complex/libraries/import.dara +11 -0
- package/tests/fixtures/complex/main.dara +2 -2
- package/tests/main.tests.js +26 -23
- package/tests/output/alias/setup.py +15 -11
- package/tests/output/alias/tea_python_tests/client.py +6 -6
- package/tests/output/annotation/setup.py +6 -4
- package/tests/output/annotation/tea_python_tests/client.py +4 -4
- package/tests/output/annotation/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/annotation/tea_python_tests/models/_test.py +1 -1
- package/tests/output/api/setup.py +6 -4
- package/tests/output/api/tea_python_tests/client.py +4 -4
- package/tests/output/builtin/setup.py +6 -4
- package/tests/output/builtin/tea_python_tests/client.py +18 -16
- package/tests/output/comment/setup.py +6 -4
- package/tests/output/comment/tea_python_tests/client.py +6 -5
- package/tests/output/comment/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/comment/tea_python_tests/models/_test_1.py +2 -1
- package/tests/output/comment/tea_python_tests/models/_test_2.py +1 -1
- package/tests/output/comment/tea_python_tests/models/_test_3.py +1 -1
- package/tests/output/complex/setup.py +6 -4
- package/tests/output/complex/tea_python_tests/client.py +17 -16
- package/tests/output/complex/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/output/complex/tea_python_tests/exceptions/_err_1.py +2 -1
- package/tests/output/complex/tea_python_tests/exceptions/_err_2.py +1 -1
- package/tests/output/complex/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/complex/tea_python_tests/models/_complex_request.py +7 -6
- package/tests/output/complex/tea_python_tests/models/_response.py +2 -2
- package/tests/output/const/setup.py +6 -4
- package/tests/output/const/tea_python_tests/client.py +0 -2
- package/tests/output/empty/setup.py +6 -4
- package/tests/output/empty/tea_python_tests/client.py +0 -2
- package/tests/output/exec/setup.py +6 -4
- package/tests/output/exec/tea_python_tests/exec_client.py +3 -2
- package/tests/output/function/setup.py +6 -4
- package/tests/output/function/tea_python_tests/client.py +2 -1
- package/tests/output/import/setup.py +5 -3
- package/tests/output/import/tea_python_tests/client.py +4 -3
- package/tests/output/map/setup.py +6 -4
- package/tests/output/map/tea_python_tests/client.py +3 -3
- package/tests/output/model/setup.py +6 -4
- package/tests/output/model/tea_python_tests/client.py +0 -2
- package/tests/output/model/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/output/model/tea_python_tests/exceptions/_main_file.py +3 -2
- package/tests/output/model/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/model/tea_python_tests/models/_class.py +1 -1
- package/tests/output/model/tea_python_tests/models/_m.py +2 -2
- package/tests/output/model/tea_python_tests/models/_main_file.py +2 -2
- package/tests/output/model/tea_python_tests/models/_model.py +1 -1
- package/tests/output/model/tea_python_tests/models/_my_model.py +13 -12
- package/tests/output/modelConfig/setup.py +6 -4
- package/tests/output/modelConfig/tea_python_tests/client.py +0 -2
- package/tests/output/modelConfig/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/output/modelConfig/tea_python_tests/exceptions/_main_file.py +3 -2
- package/tests/output/modelConfig/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/modelConfig/tea_python_tests/models/_class.py +1 -1
- package/tests/output/modelConfig/tea_python_tests/models/_m.py +2 -2
- package/tests/output/modelConfig/tea_python_tests/models/_main_file.py +2 -2
- package/tests/output/modelConfig/tea_python_tests/models/_model.py +1 -1
- package/tests/output/modelConfig/tea_python_tests/models/_my_model.py +13 -12
- package/tests/output/multi/setup.py +5 -3
- package/tests/output/multi/tea_python_tests/api.py +5 -5
- package/tests/output/multi/tea_python_tests/api_models/__init__.py +0 -2
- package/tests/output/multi/tea_python_tests/api_models/_test_model_dir_2.py +1 -1
- package/tests/output/multi/tea_python_tests/client.py +4 -3
- package/tests/output/multi/tea_python_tests/exceptions/__init__.py +0 -2
- package/tests/output/multi/tea_python_tests/exceptions/_err.py +1 -1
- package/tests/output/multi/tea_python_tests/lib/util.py +0 -1
- package/tests/output/multi/tea_python_tests/model/user.py +3 -2
- package/tests/output/multi/tea_python_tests/model/user_exceptions/__init__.py +0 -2
- package/tests/output/multi/tea_python_tests/model/user_exceptions/_err.py +1 -1
- package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_1.py +1 -1
- package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_2.py +1 -1
- package/tests/output/multi/tea_python_tests/model/user_models/__init__.py +0 -2
- package/tests/output/multi/tea_python_tests/model/user_models/_base_info.py +1 -1
- package/tests/output/multi/tea_python_tests/model/user_models/_info.py +1 -1
- package/tests/output/multi/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/multi/tea_python_tests/models/_test_model_dir.py +3 -2
- package/tests/output/statements/setup.py +6 -4
- package/tests/output/statements/tea_python_tests/client.py +3 -3
- package/tests/output/super/setup.py +6 -4
- package/tests/output/super/tea_python_tests/client.py +2 -2
- package/tests/output/typedef/setup.py +5 -3
- package/tests/output/typedef/tea_python_tests/client.py +5 -5
- package/tests/output/typedef/tea_python_tests/models/__init__.py +0 -2
- package/tests/output/typedef/tea_python_tests/models/_m.py +3 -3
package/lib/generator.js
CHANGED
|
@@ -10,7 +10,8 @@ const {
|
|
|
10
10
|
_name, _vid, _string, _upperFirst, _type, _escape,
|
|
11
11
|
_subModelName, _camelCase, _snakeCase, _getImport,
|
|
12
12
|
_isBinaryOp, _adaptedQuotes, CORE, REQUEST, RESPONSE,
|
|
13
|
-
_avoidKeywords, _removeFilesInDirectory
|
|
13
|
+
_avoidKeywords, _removeFilesInDirectory, _sortImports,
|
|
14
|
+
_importsToString,
|
|
14
15
|
} = require('./helper');
|
|
15
16
|
const getBuiltin = require('./builtin');
|
|
16
17
|
const { Tag } = require('@darabonba/parser/lib/tag');
|
|
@@ -68,7 +69,7 @@ class Visitor {
|
|
|
68
69
|
recursive: true
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
this.package = {};
|
|
72
|
+
this.package = this.config.packageInfo || {};
|
|
72
73
|
this.initSetupPy();
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -76,18 +77,18 @@ class Visitor {
|
|
|
76
77
|
// 初始化包信息
|
|
77
78
|
this.package.name = this.package.name || this.config.package;
|
|
78
79
|
this.package.version = this.package.version || '1.0.0';
|
|
79
|
-
this.package.description = this.package.
|
|
80
|
+
this.package.description = this.package.desc || '';
|
|
80
81
|
this.package.author = this.package.author || 'Alibaba';
|
|
81
|
-
this.package.author_email = this.package.
|
|
82
|
-
this.package.url = this.package.
|
|
82
|
+
this.package.author_email = this.package.email || 'sdk-team@alibabacloud.com';
|
|
83
|
+
this.package.url = this.package.github || 'https://github.com/';
|
|
83
84
|
this.package.license = this.package.license || 'Apache License 2.0';
|
|
84
|
-
this.package.requires = this.package.
|
|
85
|
-
|
|
85
|
+
this.package.requires = this.package.require || [];
|
|
86
|
+
|
|
86
87
|
// 收集依赖信息
|
|
87
88
|
if (!this.package.dependencies) {
|
|
88
89
|
this.package.dependencies = {};
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
Object.keys(this.typedef).forEach(type => {
|
|
92
93
|
if (this.typedef[type].package) {
|
|
93
94
|
let [pkgName, version] = this.typedef[type].package.split(':');
|
|
@@ -96,7 +97,8 @@ class Visitor {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
+
const date = new Date();
|
|
101
|
+
|
|
100
102
|
// 创建 setup.py 内容
|
|
101
103
|
const setupPyContent = `
|
|
102
104
|
# -*- coding: utf-8 -*-
|
|
@@ -123,14 +125,14 @@ import os
|
|
|
123
125
|
from setuptools import setup, find_packages
|
|
124
126
|
|
|
125
127
|
"""
|
|
126
|
-
setup module for
|
|
128
|
+
setup module for ${this.package.name}.
|
|
127
129
|
|
|
128
|
-
Created on
|
|
130
|
+
Created on ${('0' + date.getDate()).slice(-2) + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + '/' + date.getFullYear()}
|
|
129
131
|
|
|
130
|
-
@author:
|
|
132
|
+
@author: ${this.package.author}
|
|
131
133
|
"""
|
|
132
134
|
|
|
133
|
-
PACKAGE = "${this.package
|
|
135
|
+
PACKAGE = "${this.config.package}"
|
|
134
136
|
NAME = "${this.package.name}"
|
|
135
137
|
DESCRIPTION = "${this.package.description}"
|
|
136
138
|
AUTHOR = "${this.package.author}"
|
|
@@ -138,13 +140,13 @@ AUTHOR_EMAIL = "${this.package.author_email}"
|
|
|
138
140
|
URL = "${this.package.url}"
|
|
139
141
|
VERSION = __import__(PACKAGE).__version__
|
|
140
142
|
REQUIRES = [
|
|
141
|
-
"darabonba-core>=1.0.0, <2.0.0",
|
|
143
|
+
"darabonba-core>=1.0.0, <2.0.0"${this.package.requires.length > 0 || Object.keys(this.package.dependencies).length > 0 ? ',' : ''}
|
|
142
144
|
${Object.keys(this.package.dependencies).map(pkg => {
|
|
143
|
-
if(this.package.dependencies[pkg].includes('rc')) {
|
|
145
|
+
if (this.package.dependencies[pkg].includes('rc')) {
|
|
144
146
|
return ` "${pkg}==${this.package.dependencies[pkg]}"`;
|
|
145
147
|
}
|
|
146
148
|
return ` "${pkg}>=${this.package.dependencies[pkg]}, <${+this.package.dependencies[pkg].split('.')[0] + 1}.0.0"`;
|
|
147
|
-
}).join(',\n')}
|
|
149
|
+
}).join(',\n')}${this.package.requires.length > 0 ? ',\n "' + this.package.requires.join('",\n "') + '"' : ''}
|
|
148
150
|
]
|
|
149
151
|
|
|
150
152
|
LONG_DESCRIPTION = ''
|
|
@@ -162,34 +164,36 @@ setup(
|
|
|
162
164
|
author_email=AUTHOR_EMAIL,
|
|
163
165
|
license="Apache License 2.0",
|
|
164
166
|
url=URL,
|
|
165
|
-
keywords
|
|
167
|
+
keywords=${JSON.stringify(this.package.name ? this.package.name.split(/_|-/) : [])},
|
|
166
168
|
packages=find_packages(exclude=["tests*"]),
|
|
167
169
|
include_package_data=True,
|
|
168
170
|
platforms="any",
|
|
169
171
|
install_requires=REQUIRES,
|
|
170
|
-
python_requires=">=3.
|
|
172
|
+
python_requires=">=3.7",
|
|
171
173
|
classifiers=(
|
|
172
174
|
"Development Status :: 4 - Beta",
|
|
173
175
|
"Intended Audience :: Developers",
|
|
174
176
|
"License :: OSI Approved :: Apache Software License",
|
|
175
177
|
"Programming Language :: Python",
|
|
176
178
|
"Programming Language :: Python :: 3",
|
|
177
|
-
"Programming Language :: Python :: 3.6",
|
|
178
179
|
"Programming Language :: Python :: 3.7",
|
|
179
180
|
"Programming Language :: Python :: 3.8",
|
|
180
181
|
"Programming Language :: Python :: 3.9",
|
|
182
|
+
"Programming Language :: Python :: 3.10",
|
|
183
|
+
"Programming Language :: Python :: 3.11",
|
|
184
|
+
"Programming Language :: Python :: 3.12",
|
|
181
185
|
"Topic :: Software Development"
|
|
182
186
|
)
|
|
183
187
|
)
|
|
184
188
|
`.trim();
|
|
185
|
-
|
|
189
|
+
|
|
186
190
|
// 将内容写入 setup.py 文件
|
|
187
191
|
const setupPath = path.join(this.outputDir, 'setup.py');
|
|
188
192
|
fs.writeFileSync(setupPath, setupPyContent);
|
|
189
193
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
193
197
|
|
|
194
198
|
saveInnerModule(ast) {
|
|
195
199
|
const keys = ast.innerModule.keys();
|
|
@@ -213,7 +217,7 @@ setup(
|
|
|
213
217
|
|
|
214
218
|
save(filepath) {
|
|
215
219
|
let targetPath = filepath;
|
|
216
|
-
if(path.resolve(filepath).startsWith(path.resolve(this.outputDir))) {
|
|
220
|
+
if (path.resolve(filepath).startsWith(path.resolve(this.outputDir))) {
|
|
217
221
|
const baseDir = path.join(this.outputDir, path.sep);
|
|
218
222
|
filepath = filepath.replace(baseDir, '');
|
|
219
223
|
}
|
|
@@ -238,18 +242,18 @@ setup(
|
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
overwrite(ast, filepath) {
|
|
241
|
-
if(!ast.moduleBody.nodes || !ast.moduleBody.nodes.length) {
|
|
245
|
+
if (!ast.moduleBody.nodes || !ast.moduleBody.nodes.length) {
|
|
242
246
|
return;
|
|
243
247
|
}
|
|
244
248
|
const beginNotes = DSL.note.getNotes(this.notes, 0, ast.moduleBody.nodes[0].tokenRange[0]);
|
|
245
249
|
const overwirte = beginNotes.find(note => note.note.lexeme === '@overwrite');
|
|
246
250
|
let targetPath = filepath;
|
|
247
|
-
if(path.resolve(filepath).startsWith(path.resolve(this.outputDir))) {
|
|
251
|
+
if (path.resolve(filepath).startsWith(path.resolve(this.outputDir))) {
|
|
248
252
|
const baseDir = path.join(this.outputDir, path.sep);
|
|
249
253
|
filepath = filepath.replace(baseDir, '');
|
|
250
254
|
}
|
|
251
255
|
targetPath = path.join(this.outputDir, filepath);
|
|
252
|
-
if(overwirte && overwirte.arg.value === false && fs.existsSync(targetPath)) {
|
|
256
|
+
if (overwirte && overwirte.arg.value === false && fs.existsSync(targetPath)) {
|
|
253
257
|
return false;
|
|
254
258
|
}
|
|
255
259
|
return true;
|
|
@@ -257,7 +261,7 @@ setup(
|
|
|
257
261
|
|
|
258
262
|
modelBefore() {
|
|
259
263
|
// clear model.py
|
|
260
|
-
if(fs.existsSync(this.modelPath + '.py')) {
|
|
264
|
+
if (fs.existsSync(this.modelPath + '.py')) {
|
|
261
265
|
fs.unlinkSync(this.modelPath + '.py');
|
|
262
266
|
}
|
|
263
267
|
_removeFilesInDirectory(this.modelPath);
|
|
@@ -266,8 +270,8 @@ setup(
|
|
|
266
270
|
|
|
267
271
|
visitModuleInit() {
|
|
268
272
|
const initFile = path.join(this.outputDir, this.config.package, '__init__.py');
|
|
269
|
-
if(!fs.existsSync(initFile)) {
|
|
270
|
-
if(!fs.existsSync(path.dirname(initFile))) {
|
|
273
|
+
if (!fs.existsSync(initFile)) {
|
|
274
|
+
if (!fs.existsSync(path.dirname(initFile))) {
|
|
271
275
|
fs.mkdirSync(path.dirname(initFile), {
|
|
272
276
|
recursive: true
|
|
273
277
|
});
|
|
@@ -293,11 +297,11 @@ setup(
|
|
|
293
297
|
this.fileBuffer = {};
|
|
294
298
|
this.usedTypes = [];
|
|
295
299
|
this.imports = [];
|
|
296
|
-
if(this.overwrite(ast, filepath) === false) {
|
|
300
|
+
if (this.overwrite(ast, filepath) === false) {
|
|
297
301
|
return;
|
|
298
302
|
}
|
|
299
303
|
|
|
300
|
-
if(!this.className) {
|
|
304
|
+
if (!this.className) {
|
|
301
305
|
let clientName = this.config.clientName.replace(/(?:^|_)([a-z])/g, (_, c) => (c ? c.toUpperCase() : ''));
|
|
302
306
|
this.className = clientName;
|
|
303
307
|
}
|
|
@@ -335,7 +339,7 @@ setup(
|
|
|
335
339
|
return item.type === 'exception';
|
|
336
340
|
});
|
|
337
341
|
|
|
338
|
-
|
|
342
|
+
|
|
339
343
|
if (exceptions.length > 0) {
|
|
340
344
|
for (let i = 0; i < exceptions.length; i++) {
|
|
341
345
|
this.eachException(exceptions[i], level);
|
|
@@ -350,7 +354,7 @@ setup(
|
|
|
350
354
|
|
|
351
355
|
this.visitAnnotation(ast.annotation, level);
|
|
352
356
|
|
|
353
|
-
|
|
357
|
+
|
|
354
358
|
|
|
355
359
|
// models definition
|
|
356
360
|
this.apiBefore(level);
|
|
@@ -380,7 +384,7 @@ setup(
|
|
|
380
384
|
this.emit(` def __init__(self):
|
|
381
385
|
pass\n`);
|
|
382
386
|
}
|
|
383
|
-
|
|
387
|
+
|
|
384
388
|
const apis = ast.moduleBody.nodes.filter((item) => {
|
|
385
389
|
return item.type === 'api';
|
|
386
390
|
});
|
|
@@ -558,7 +562,7 @@ setup(
|
|
|
558
562
|
this.visitType(item.value);
|
|
559
563
|
this.emit(' = None\n', level);
|
|
560
564
|
});
|
|
561
|
-
if(ast.params.params.length !== 0) {
|
|
565
|
+
if (ast.params.params.length !== 0) {
|
|
562
566
|
this.emit('\n');
|
|
563
567
|
this.emit('def __init__(\n', level + 2);
|
|
564
568
|
this.emit('self,\n', level + 4);
|
|
@@ -577,7 +581,7 @@ setup(
|
|
|
577
581
|
} else {
|
|
578
582
|
this.emit('def __init__(self):\n', level + 2);
|
|
579
583
|
}
|
|
580
|
-
if (ast.initBody && ast.initBody.stmts.length !==0
|
|
584
|
+
if (ast.initBody && ast.initBody.stmts.length !== 0) {
|
|
581
585
|
this.isStaticFunction = false;
|
|
582
586
|
this.visitStmts(ast.initBody, level + 4);
|
|
583
587
|
this.isStaticFunction = true;
|
|
@@ -609,7 +613,7 @@ setup(
|
|
|
609
613
|
pyPath = pyPath.split('/').map(dir => _snakeCase(dir)).join(path.sep);
|
|
610
614
|
pyPath = `${pyPath}`;
|
|
611
615
|
}
|
|
612
|
-
|
|
616
|
+
|
|
613
617
|
const classNamespace = this.getClassNamespace(pyPath);
|
|
614
618
|
const className = this.getInnerClient(aliasId, pyPath);
|
|
615
619
|
const aliasName = this.getAliasName(className, aliasId);
|
|
@@ -628,7 +632,7 @@ setup(
|
|
|
628
632
|
}
|
|
629
633
|
let targetPath = '';
|
|
630
634
|
if (moduleDir.startsWith('./') || moduleDir.startsWith('../')) {
|
|
631
|
-
targetPath = path.join(
|
|
635
|
+
targetPath = path.join(this.config.pkgDir, moduleDir);
|
|
632
636
|
} else if (moduleDir.startsWith('/')) {
|
|
633
637
|
targetPath = moduleDir;
|
|
634
638
|
} else {
|
|
@@ -646,7 +650,7 @@ setup(
|
|
|
646
650
|
let classNamespace = pyPkg.package;
|
|
647
651
|
let models = 'models';
|
|
648
652
|
let exceptions = 'exceptions';
|
|
649
|
-
if(inner && pkg.exports[inner]) {
|
|
653
|
+
if (inner && pkg.exports[inner]) {
|
|
650
654
|
let pyPath = pkg.exports[inner];
|
|
651
655
|
filename = pyPath.split(path.sep).slice(-1)[0].replace(/(\.tea)$|(\.spec)$|(\.dara)$/gi, '');
|
|
652
656
|
models = filename + '_models';
|
|
@@ -669,7 +673,7 @@ setup(
|
|
|
669
673
|
};
|
|
670
674
|
// 这部分处理setup.py
|
|
671
675
|
if (pkg.releases && pkg.releases.python) {
|
|
672
|
-
const REQUIRE = pkg.releases.python
|
|
676
|
+
const REQUIRE = pkg.releases.python;
|
|
673
677
|
const [pkgName, version] = REQUIRE.split(':');
|
|
674
678
|
this.package.dependencies[pkgName] = `${version}`;
|
|
675
679
|
}
|
|
@@ -699,7 +703,7 @@ setup(
|
|
|
699
703
|
className: this.moduleTypedef[aliasId][type].type,
|
|
700
704
|
});
|
|
701
705
|
}
|
|
702
|
-
|
|
706
|
+
|
|
703
707
|
return this.getTypedefType(this.moduleTypedef[aliasId][type].type);
|
|
704
708
|
}
|
|
705
709
|
}
|
|
@@ -719,19 +723,19 @@ setup(
|
|
|
719
723
|
}
|
|
720
724
|
|
|
721
725
|
getTypedefType(type) {
|
|
722
|
-
if(/\bDict\b/.test(type)) {
|
|
726
|
+
if (/\bDict\b/.test(type)) {
|
|
723
727
|
this.usedTypes.push('Dict');
|
|
724
728
|
}
|
|
725
729
|
|
|
726
|
-
if(/\bList\b/.test(type)) {
|
|
730
|
+
if (/\bList\b/.test(type)) {
|
|
727
731
|
this.usedTypes.push('List');
|
|
728
732
|
}
|
|
729
733
|
|
|
730
|
-
if(/\bAny\b/.test(type)) {
|
|
734
|
+
if (/\bAny\b/.test(type)) {
|
|
731
735
|
this.usedTypes.push('Any');
|
|
732
736
|
}
|
|
733
737
|
|
|
734
|
-
if(/\bBinaryIO\b/.test(type)) {
|
|
738
|
+
if (/\bBinaryIO\b/.test(type)) {
|
|
735
739
|
this.usedTypes.push('BinaryIO');
|
|
736
740
|
}
|
|
737
741
|
|
|
@@ -746,7 +750,7 @@ setup(
|
|
|
746
750
|
return;
|
|
747
751
|
}
|
|
748
752
|
this.emit('(\n');
|
|
749
|
-
if (instanceFunc){
|
|
753
|
+
if (instanceFunc) {
|
|
750
754
|
this.emit('self,\n', level);
|
|
751
755
|
}
|
|
752
756
|
for (var i = 0; i < ast.params.length; i++) {
|
|
@@ -761,7 +765,7 @@ setup(
|
|
|
761
765
|
}
|
|
762
766
|
}
|
|
763
767
|
this.emit('\n');
|
|
764
|
-
this.emit(')',level - 2);
|
|
768
|
+
this.emit(')', level - 2);
|
|
765
769
|
}
|
|
766
770
|
|
|
767
771
|
visitType(ast, level) {
|
|
@@ -829,17 +833,17 @@ setup(
|
|
|
829
833
|
this.emit(typeName);
|
|
830
834
|
}
|
|
831
835
|
}
|
|
832
|
-
|
|
836
|
+
|
|
833
837
|
visitTypeWithNone(ast, level) {
|
|
834
838
|
this.visitType(ast, level);
|
|
835
839
|
this.emit(' = None');
|
|
836
840
|
}
|
|
837
|
-
|
|
841
|
+
|
|
838
842
|
|
|
839
843
|
visitReturnType(ast, level) {
|
|
840
844
|
this.emit(' -> ');
|
|
841
|
-
if(this.isIterator(ast.returnType)) {
|
|
842
|
-
if(this.isAsyncFunction) {
|
|
845
|
+
if (this.isIterator(ast.returnType)) {
|
|
846
|
+
if (this.isAsyncFunction) {
|
|
843
847
|
this.usedTypes.push('AsyncGenerator');
|
|
844
848
|
this.emit('AsyncGenerator[');
|
|
845
849
|
} else {
|
|
@@ -847,7 +851,7 @@ setup(
|
|
|
847
851
|
this.emit('Generator[');
|
|
848
852
|
}
|
|
849
853
|
}
|
|
850
|
-
|
|
854
|
+
|
|
851
855
|
this.visitType(ast.returnType, level);
|
|
852
856
|
if (this.isIterator(ast.returnType)) {
|
|
853
857
|
this.emit(', None, None]');
|
|
@@ -864,16 +868,16 @@ setup(
|
|
|
864
868
|
visitRuntimeBefore(ast, level) {
|
|
865
869
|
assert.equal(ast.type, 'object');
|
|
866
870
|
this.emit('_runtime = {\n', level + 2);
|
|
867
|
-
if(ast.fields.length !== 0){
|
|
871
|
+
if (ast.fields.length !== 0) {
|
|
868
872
|
ast.fields.forEach((field) => {
|
|
869
873
|
this.emit(`'${field.fieldName.lexeme}': `, level + 4);
|
|
870
874
|
this.visitExpr(field.expr);
|
|
871
875
|
this.emit(',\n');
|
|
872
876
|
});
|
|
873
877
|
}
|
|
874
|
-
this.emit('}\n', level +2);
|
|
875
|
-
this.emit('_last_request = None\n', level+2);
|
|
876
|
-
this.emit('_last_response = None\n', level+2);
|
|
878
|
+
this.emit('}\n', level + 2);
|
|
879
|
+
this.emit('_last_request = None\n', level + 2);
|
|
880
|
+
this.emit('_last_response = None\n', level + 2);
|
|
877
881
|
this.emit('_retries_attempted = 0\n', level + 2);
|
|
878
882
|
this.emit(`_context = RetryPolicyContext(
|
|
879
883
|
retries_attempted= _retries_attempted
|
|
@@ -956,16 +960,16 @@ setup(
|
|
|
956
960
|
if (externEx && externEx.has(modelName)) {
|
|
957
961
|
type = 'exception';
|
|
958
962
|
}
|
|
959
|
-
|
|
963
|
+
|
|
960
964
|
this.emit(this.getModelName(modelName, _name(moduleId)), type);
|
|
961
|
-
|
|
965
|
+
|
|
962
966
|
} else if (value.type === 'subModel') {
|
|
963
967
|
const [moduleId, ...rest] = value.path;
|
|
964
968
|
const modelName = _subModelName([moduleId.lexeme, ...rest.map((item) => {
|
|
965
969
|
return item.lexeme;
|
|
966
970
|
})].join('.'));
|
|
967
971
|
this.emit(this.getModelName(modelName));
|
|
968
|
-
} else if (typeof value.fieldType === 'string'){
|
|
972
|
+
} else if (typeof value.fieldType === 'string') {
|
|
969
973
|
const type = _type(value.fieldType);
|
|
970
974
|
this.pushImports(type);
|
|
971
975
|
this.emit(type);
|
|
@@ -978,7 +982,7 @@ setup(
|
|
|
978
982
|
type = 'exception';
|
|
979
983
|
}
|
|
980
984
|
this.emit(this.getModelName(modelName, _name(moduleId), type));
|
|
981
|
-
|
|
985
|
+
|
|
982
986
|
} else if (value.fieldType.type === 'moduleTypedef') {
|
|
983
987
|
const [moduleId, ...rest] = value.fieldType.path;
|
|
984
988
|
const type = rest.map((item) => { return item.lexeme; }).join('.');
|
|
@@ -1015,7 +1019,7 @@ setup(
|
|
|
1015
1019
|
assert.equal(ast.type, 'modelBody');
|
|
1016
1020
|
this.visitFieldsInit(ast, level, modelName);
|
|
1017
1021
|
let node;
|
|
1018
|
-
|
|
1022
|
+
|
|
1019
1023
|
for (let i = 0; i < ast.nodes.length; i++) {
|
|
1020
1024
|
node = ast.nodes[i];
|
|
1021
1025
|
let comments = DSL.comment.getFrontComments(this.comments, node.tokenRange[0]);
|
|
@@ -1033,7 +1037,7 @@ setup(
|
|
|
1033
1037
|
this.emit('\n');
|
|
1034
1038
|
// validate
|
|
1035
1039
|
this.emit('def validate(self):\n', level);
|
|
1036
|
-
if(ast.nodes.length > 0) {
|
|
1040
|
+
if (ast.nodes.length > 0) {
|
|
1037
1041
|
this.visitModelValidate(ast, level);
|
|
1038
1042
|
} else {
|
|
1039
1043
|
this.emit('pass\n', level + 2);
|
|
@@ -1047,7 +1051,7 @@ setup(
|
|
|
1047
1051
|
|
|
1048
1052
|
// from_map
|
|
1049
1053
|
this.visitFromMap(ast, modelName, level);
|
|
1050
|
-
|
|
1054
|
+
|
|
1051
1055
|
if (node) {
|
|
1052
1056
|
//find the last node's back comment
|
|
1053
1057
|
let comments = DSL.comment.getBetweenComments(this.comments, node.tokenRange[0], ast.tokenRange[1]);
|
|
@@ -1064,11 +1068,11 @@ setup(
|
|
|
1064
1068
|
|
|
1065
1069
|
visitFieldValidate(fieldValue, fieldName, value, level) {
|
|
1066
1070
|
const deep = Math.floor(level / 4);
|
|
1067
|
-
if (fieldValue.type === 'modelBody' || fieldValue.type === 'moduleModel' ||
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
if(deep > 1) {
|
|
1071
|
+
if (fieldValue.type === 'modelBody' || fieldValue.type === 'moduleModel' ||
|
|
1072
|
+
fieldValue.type === 'subModel' || fieldValue.idType === 'model' ||
|
|
1073
|
+
(fieldValue.fieldType && (fieldValue.fieldType.type === 'moduleModel' ||
|
|
1074
|
+
fieldValue.fieldType.idType === 'model' || fieldValue.fieldType.idType === 'builtin_model'))) {
|
|
1075
|
+
if (deep > 1) {
|
|
1072
1076
|
this.emit(` if ${value}:\n`, level);
|
|
1073
1077
|
}
|
|
1074
1078
|
this.emit(`${value}.validate()\n`, level + 2);
|
|
@@ -1079,7 +1083,7 @@ setup(
|
|
|
1079
1083
|
this.emit(`for v${deep} in self.${fieldName}.values():\n`, level);
|
|
1080
1084
|
this.visitFieldValidate(fieldValue.valueType, fieldName, `v${deep}`, level + 2);
|
|
1081
1085
|
} else {
|
|
1082
|
-
if(deep > 1) {
|
|
1086
|
+
if (deep > 1) {
|
|
1083
1087
|
this.emit(` if ${value}:\n`, level);
|
|
1084
1088
|
}
|
|
1085
1089
|
this.emit(`${value}.validate()\n`, level + 2);
|
|
@@ -1101,95 +1105,95 @@ setup(
|
|
|
1101
1105
|
// 这里判断类中属性是否是必填
|
|
1102
1106
|
if (node.required) {
|
|
1103
1107
|
notPass = true;
|
|
1104
|
-
this.emit(`self.validate_required(self.${param}, '${param}')\n`, level + 2);
|
|
1108
|
+
this.emit(`self.validate_required(self.${param}, '${param}')\n`, level + 2);
|
|
1105
1109
|
}
|
|
1106
1110
|
// 这里判断类中属性的结构
|
|
1107
|
-
if(node.fieldValue.fieldType === 'array' || node.fieldValue.fieldType === 'map' ||
|
|
1111
|
+
if (node.fieldValue.fieldType === 'array' || node.fieldValue.fieldType === 'map' ||
|
|
1108
1112
|
node.fieldValue.type === 'array' || node.fieldValue.type === 'map'
|
|
1109
1113
|
) {
|
|
1110
1114
|
// 下面不包含model的就不需要validate
|
|
1111
|
-
if(!this.checkFieldHasModel(node.fieldValue)){
|
|
1115
|
+
if (!this.checkFieldHasModel(node.fieldValue)) {
|
|
1112
1116
|
continue;
|
|
1113
1117
|
}
|
|
1114
1118
|
notPass = true;
|
|
1115
1119
|
this.emit(`if self.${param}:\n`, level + 2);
|
|
1116
1120
|
this.visitFieldValidate(node.fieldValue, param, `self.${param}`, level + 4);
|
|
1117
|
-
} else if(node.fieldValue.fieldType && node.fieldValue.fieldType.idType === 'model' || node.fieldValue.type === 'modelBody'){
|
|
1121
|
+
} else if (node.fieldValue.fieldType && node.fieldValue.fieldType.idType === 'model' || node.fieldValue.type === 'modelBody') {
|
|
1118
1122
|
notPass = true;
|
|
1119
1123
|
this.emit(`if self.${param}:\n`, level + 2);
|
|
1120
1124
|
this.emit(`self.${param}.validate()\n`, level + 4);
|
|
1121
|
-
} else if(pattern !== ''){
|
|
1125
|
+
} else if (pattern !== '') {
|
|
1122
1126
|
notPass = true;
|
|
1123
1127
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1124
1128
|
this.emit(`self.validate_pattern(self.${param}, '${param}', '${pattern}')\n`, level + 4);
|
|
1125
|
-
} else if(maxLength > 0 && maxLength <= 2147483647){
|
|
1129
|
+
} else if (maxLength > 0 && maxLength <= 2147483647) {
|
|
1126
1130
|
notPass = true;
|
|
1127
1131
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1128
1132
|
this.emit(`self.validate_max_length(self.${param}, '${param}', ${maxLength})\n`, level + 4);
|
|
1129
|
-
} else if(minLength > 0 && minLength <= 2147483647){
|
|
1133
|
+
} else if (minLength > 0 && minLength <= 2147483647) {
|
|
1130
1134
|
notPass = true;
|
|
1131
1135
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1132
1136
|
this.emit(`self.validate_min_length(self.${param}, '${param}', ${minLength})\n`, level + 4);
|
|
1133
|
-
} else if(maximum > 0 && maximum <= Number.MAX_SAFE_INTEGER){
|
|
1137
|
+
} else if (maximum > 0 && maximum <= Number.MAX_SAFE_INTEGER) {
|
|
1134
1138
|
notPass = true;
|
|
1135
1139
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1136
1140
|
this.emit(`self.validate_maximum(self.${param}, '${param}', ${maximum})\n`, level + 4);
|
|
1137
|
-
} else if(minimum > 0 && minimum <= Number.MAX_SAFE_INTEGER){
|
|
1141
|
+
} else if (minimum > 0 && minimum <= Number.MAX_SAFE_INTEGER) {
|
|
1138
1142
|
notPass = true;
|
|
1139
1143
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1140
1144
|
this.emit(`self.validate_minimum(self.${param}, '${param}', ${minimum})\n`, level + 4);
|
|
1141
1145
|
}
|
|
1142
1146
|
}
|
|
1143
1147
|
|
|
1144
|
-
if(!notPass) {
|
|
1148
|
+
if (!notPass) {
|
|
1145
1149
|
this.emit('pass\n', level + 2);
|
|
1146
1150
|
}
|
|
1147
1151
|
}
|
|
1148
1152
|
|
|
1149
1153
|
visitToMapField(fieldValue, fieldName, key, value, level, arr = false) {
|
|
1150
1154
|
const deep = Math.floor((level - 4) / 2);
|
|
1151
|
-
if (fieldValue.type === 'modelBody' || fieldValue.type === 'moduleModel' ||
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
+
if (fieldValue.type === 'modelBody' || fieldValue.type === 'moduleModel' ||
|
|
1156
|
+
fieldValue.type === 'subModel' || fieldValue.idType === 'model' ||
|
|
1157
|
+
(fieldValue.fieldType && (fieldValue.fieldType.type === 'moduleModel' ||
|
|
1158
|
+
fieldValue.fieldType.idType === 'model' || fieldValue.fieldType.idType === 'builtin_model'))) {
|
|
1155
1159
|
let realVal = `${value}.to_map()`;
|
|
1156
|
-
if(deep > 1) {
|
|
1160
|
+
if (deep > 1) {
|
|
1157
1161
|
realVal += ` if ${value} else None`;
|
|
1158
1162
|
}
|
|
1159
1163
|
this.emitFieldConvert(key, realVal, level, arr);
|
|
1160
1164
|
} else if (fieldValue.type === 'array' || fieldValue.fieldType === 'array') {
|
|
1161
|
-
let subKey
|
|
1162
|
-
if(deep > 1) {
|
|
1165
|
+
let subKey = key;
|
|
1166
|
+
if (deep > 1) {
|
|
1163
1167
|
subKey = `l${deep - 1}`;
|
|
1164
1168
|
this.emit(`${subKey} = []\n`, level);
|
|
1165
1169
|
}
|
|
1166
1170
|
this.emit(`for k${deep} in ${value}:\n`, level);
|
|
1167
1171
|
this.visitToMapField(fieldValue.fieldItemType || fieldValue.subType, fieldName, `${subKey}`, `k${deep}`, level + 2, true);
|
|
1168
|
-
if(deep > 1) {
|
|
1172
|
+
if (deep > 1) {
|
|
1169
1173
|
this.emitFieldConvert(key, subKey, level, arr);
|
|
1170
1174
|
}
|
|
1171
1175
|
} else if (fieldValue.fieldType === 'map' || fieldValue.type === 'map') {
|
|
1172
|
-
let subKey
|
|
1173
|
-
if(deep > 1) {
|
|
1176
|
+
let subKey = key;
|
|
1177
|
+
if (deep > 1) {
|
|
1174
1178
|
subKey = `d${deep - 1}`;
|
|
1175
1179
|
this.emit(`${subKey} = {}\n`, level);
|
|
1176
1180
|
}
|
|
1177
1181
|
this.emit(`for k${deep}, v${deep} in self.${fieldName}.items():\n`, level);
|
|
1178
1182
|
this.visitToMapField(fieldValue.valueType, fieldName, `${subKey}[k${deep}]`, `v${deep}`, level + 2);
|
|
1179
|
-
if(deep > 1) {
|
|
1183
|
+
if (deep > 1) {
|
|
1180
1184
|
this.emitFieldConvert(key, subKey, level, arr);
|
|
1181
1185
|
}
|
|
1182
1186
|
} else {
|
|
1183
1187
|
this.emitFieldConvert(key, value, level, arr);
|
|
1184
1188
|
}
|
|
1185
|
-
|
|
1189
|
+
|
|
1186
1190
|
}
|
|
1187
1191
|
|
|
1188
1192
|
visitToMap(ast, level) {
|
|
1189
1193
|
this.emit('def to_map(self):\n', level);
|
|
1190
|
-
this.emit('result = dict()\n'
|
|
1191
|
-
this.emit('_map = super().to_map()\n'
|
|
1192
|
-
this.emit('if _map is not None:\n'
|
|
1194
|
+
this.emit('result = dict()\n', level + 2);
|
|
1195
|
+
this.emit('_map = super().to_map()\n', level + 2);
|
|
1196
|
+
this.emit('if _map is not None:\n', level + 2);
|
|
1193
1197
|
this.emit('result = _map\n', level + 4);
|
|
1194
1198
|
for (let i = 0; i < ast.nodes.length; i++) {
|
|
1195
1199
|
const node = ast.nodes[i];
|
|
@@ -1199,7 +1203,7 @@ setup(
|
|
|
1199
1203
|
let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
|
|
1200
1204
|
const hasModel = this.checkFieldHasModel(node.fieldValue);
|
|
1201
1205
|
let arr = false;
|
|
1202
|
-
if(hasModel && !this.config.noneEmpty) {
|
|
1206
|
+
if (hasModel && !this.config.noneEmpty) {
|
|
1203
1207
|
if (node.fieldValue.type === 'array' || node.fieldValue.fieldType === 'array') {
|
|
1204
1208
|
this.emit(`result['${realName}'] = []\n`, level + 2);
|
|
1205
1209
|
arr = true;
|
|
@@ -1208,10 +1212,10 @@ setup(
|
|
|
1208
1212
|
}
|
|
1209
1213
|
}
|
|
1210
1214
|
this.emit(`if self.${param} is not None:\n`, level + 2);
|
|
1211
|
-
if(!hasModel) {
|
|
1215
|
+
if (!hasModel) {
|
|
1212
1216
|
this.emit(`result['${realName}'] = self.${param}\n`, level + 4);
|
|
1213
1217
|
} else {
|
|
1214
|
-
if(this.config.noneEmpty) {
|
|
1218
|
+
if (this.config.noneEmpty) {
|
|
1215
1219
|
if (node.fieldValue.type === 'array' || node.fieldValue.fieldType === 'array') {
|
|
1216
1220
|
this.emit(`result['${realName}'] = []\n`, level + 4);
|
|
1217
1221
|
arr = true;
|
|
@@ -1228,7 +1232,7 @@ setup(
|
|
|
1228
1232
|
}
|
|
1229
1233
|
|
|
1230
1234
|
emitFieldConvert(key, value, level, arr) {
|
|
1231
|
-
if(arr) {
|
|
1235
|
+
if (arr) {
|
|
1232
1236
|
this.emit(`${key}.append(${value})\n`, level);
|
|
1233
1237
|
return;
|
|
1234
1238
|
}
|
|
@@ -1242,29 +1246,29 @@ setup(
|
|
|
1242
1246
|
this.emit(`temp_model = ${this.getModelName(subModelName)}()\n`, level);
|
|
1243
1247
|
this.emitFieldConvert(key, `temp_model.from_map(${value})`, level, arr);
|
|
1244
1248
|
} else if (fieldValue.type === 'array' || fieldValue.fieldType === 'array') {
|
|
1245
|
-
this.emit(`for k${deep} in ${value}:\n`, level);
|
|
1246
1249
|
let subKey = key;
|
|
1247
|
-
if(deep > 1) {
|
|
1250
|
+
if (deep > 1) {
|
|
1248
1251
|
subKey = `l${deep - 1}`;
|
|
1249
|
-
this.emit(`${subKey} = []\n`, level
|
|
1252
|
+
this.emit(`${subKey} = []\n`, level);
|
|
1250
1253
|
}
|
|
1254
|
+
this.emit(`for k${deep} in ${value}:\n`, level);
|
|
1251
1255
|
this.visitFromField(fieldValue.fieldItemType || fieldValue.subType, fieldName, `${subKey}`, `k${deep}`, level + 2, true);
|
|
1252
|
-
if(deep > 1) {
|
|
1256
|
+
if (deep > 1) {
|
|
1253
1257
|
this.emitFieldConvert(key, subKey, level, arr);
|
|
1254
1258
|
}
|
|
1255
1259
|
} else if (fieldValue.fieldType === 'map' || fieldValue.type === 'map') {
|
|
1256
|
-
this.emit(`for k${deep}, v${deep} in ${value}.items():\n`, level);
|
|
1257
1260
|
let subKey = key;
|
|
1258
|
-
if(deep > 1) {
|
|
1261
|
+
if (deep > 1) {
|
|
1259
1262
|
subKey = `d${deep - 1}`;
|
|
1260
|
-
this.emit(`${subKey} = {}\n`, level
|
|
1263
|
+
this.emit(`${subKey} = {}\n`, level);
|
|
1261
1264
|
}
|
|
1265
|
+
this.emit(`for k${deep}, v${deep} in ${value}.items():\n`, level);
|
|
1262
1266
|
this.visitFromField(fieldValue.valueType, fieldName, `${subKey}[k${deep}]`, `v${deep}`, level + 2);
|
|
1263
|
-
if(deep > 1) {
|
|
1267
|
+
if (deep > 1) {
|
|
1264
1268
|
this.emitFieldConvert(key, subKey, level, arr);
|
|
1265
1269
|
}
|
|
1266
|
-
} else if (fieldValue.type === 'moduleModel' ||
|
|
1267
|
-
|
|
1270
|
+
} else if (fieldValue.type === 'moduleModel' ||
|
|
1271
|
+
(fieldValue.fieldType && fieldValue.fieldType.type === 'moduleModel')) {
|
|
1268
1272
|
const [moduleId, ...rest] = fieldValue.path || fieldValue.fieldType.path;
|
|
1269
1273
|
const modelName = _subModelName(rest.map((item) => {
|
|
1270
1274
|
return item.lexeme;
|
|
@@ -1294,7 +1298,7 @@ setup(
|
|
|
1294
1298
|
} else {
|
|
1295
1299
|
this.emitFieldConvert(key, value, level, arr);
|
|
1296
1300
|
}
|
|
1297
|
-
|
|
1301
|
+
|
|
1298
1302
|
}
|
|
1299
1303
|
|
|
1300
1304
|
visitFromMap(ast, modelName, level) {
|
|
@@ -1309,7 +1313,7 @@ setup(
|
|
|
1309
1313
|
let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
|
|
1310
1314
|
const hasModel = this.checkFieldHasModel(node.fieldValue);
|
|
1311
1315
|
let arr = false;
|
|
1312
|
-
if(hasModel && !this.config.noneEmpty) {
|
|
1316
|
+
if (hasModel && !this.config.noneEmpty) {
|
|
1313
1317
|
if (node.fieldValue.type === 'array' || node.fieldValue.fieldType === 'array') {
|
|
1314
1318
|
this.emit(`self.${param} = []\n`, level + 2);
|
|
1315
1319
|
arr = true;
|
|
@@ -1319,10 +1323,10 @@ setup(
|
|
|
1319
1323
|
}
|
|
1320
1324
|
}
|
|
1321
1325
|
this.emit(`if m.get('${realName}') is not None:\n`, level + 2);
|
|
1322
|
-
if(!hasModel) {
|
|
1326
|
+
if (!hasModel) {
|
|
1323
1327
|
this.emit(`self.${param} = m.get('${realName}')\n`, level + 4);
|
|
1324
1328
|
} else {
|
|
1325
|
-
if(this.config.noneEmpty) {
|
|
1329
|
+
if (this.config.noneEmpty) {
|
|
1326
1330
|
if (node.fieldValue.type === 'array' || node.fieldValue.fieldType === 'array') {
|
|
1327
1331
|
this.emit(`self.${param} = []\n`, level + 4);
|
|
1328
1332
|
arr = true;
|
|
@@ -1339,21 +1343,21 @@ setup(
|
|
|
1339
1343
|
this.emit('\n');
|
|
1340
1344
|
}
|
|
1341
1345
|
|
|
1342
|
-
getAttributes(ast, name){
|
|
1346
|
+
getAttributes(ast, name) {
|
|
1343
1347
|
const attr = ast.attrs.find((item) => {
|
|
1344
1348
|
return item.attrName.lexeme === name;
|
|
1345
1349
|
});
|
|
1346
|
-
if(!attr) {
|
|
1350
|
+
if (!attr) {
|
|
1347
1351
|
return;
|
|
1348
1352
|
}
|
|
1349
1353
|
return attr.attrValue.string || attr.attrValue.lexeme || attr.attrValue.value;
|
|
1350
1354
|
}
|
|
1351
1355
|
|
|
1352
|
-
extendBaseErr(extendOn){
|
|
1356
|
+
extendBaseErr(extendOn) {
|
|
1353
1357
|
if (!extendOn) {
|
|
1354
1358
|
return true;
|
|
1355
1359
|
}
|
|
1356
|
-
if(_name(extendOn) === '$Error') {
|
|
1360
|
+
if (_name(extendOn) === '$Error') {
|
|
1357
1361
|
return true;
|
|
1358
1362
|
}
|
|
1359
1363
|
|
|
@@ -1366,21 +1370,21 @@ setup(
|
|
|
1366
1370
|
return type === 'model' ? this.emit(`(${CORE}Model)`) : this.emit(`(${CORE}Exception)`);
|
|
1367
1371
|
}
|
|
1368
1372
|
|
|
1369
|
-
switch(_name(extendOn)) {
|
|
1370
|
-
case '$Error':
|
|
1373
|
+
switch (_name(extendOn)) {
|
|
1374
|
+
case '$Error':
|
|
1371
1375
|
this.pushImports(`${CORE}Exception`);
|
|
1372
1376
|
this.emit(`(${CORE}Exception)`);
|
|
1373
1377
|
return;
|
|
1374
|
-
case '$ResponseError':
|
|
1378
|
+
case '$ResponseError':
|
|
1375
1379
|
this.pushImports('ResponseException');
|
|
1376
1380
|
this.emit('(ResponseException)');
|
|
1377
1381
|
return;
|
|
1378
|
-
case '$Model':
|
|
1382
|
+
case '$Model':
|
|
1379
1383
|
this.pushImports(`${CORE}Model`);
|
|
1380
1384
|
this.emit(`(${CORE}Model)`);
|
|
1381
1385
|
return;
|
|
1382
1386
|
}
|
|
1383
|
-
|
|
1387
|
+
|
|
1384
1388
|
let needBaseException = false;
|
|
1385
1389
|
|
|
1386
1390
|
if (extendOn.type === 'moduleModel') {
|
|
@@ -1406,7 +1410,7 @@ setup(
|
|
|
1406
1410
|
this.emit('(');
|
|
1407
1411
|
this.emit(this.getModelName(_upperFirst(_name(extendOn)), extendOn.moduleName, type));
|
|
1408
1412
|
}
|
|
1409
|
-
if(needBaseException) {
|
|
1413
|
+
if (needBaseException) {
|
|
1410
1414
|
this.emit(`, ${CORE}Exception`);
|
|
1411
1415
|
}
|
|
1412
1416
|
this.emit(')');
|
|
@@ -1420,11 +1424,11 @@ setup(
|
|
|
1420
1424
|
fileds.push(fieldName);
|
|
1421
1425
|
}
|
|
1422
1426
|
const extendFileds = [];
|
|
1423
|
-
for (let i = 0; i < ast.extendFileds.length; i++) {
|
|
1427
|
+
for (let i = 0; i < ast.extendFileds.length; i++) {
|
|
1424
1428
|
const node = ast.extendFileds[i];
|
|
1425
1429
|
node.extend = true;
|
|
1426
1430
|
const fieldName = _name(node.fieldName);
|
|
1427
|
-
if(fileds.includes(fieldName)) {
|
|
1431
|
+
if (fileds.includes(fieldName)) {
|
|
1428
1432
|
continue;
|
|
1429
1433
|
}
|
|
1430
1434
|
extendFileds.push(node);
|
|
@@ -1446,7 +1450,7 @@ setup(
|
|
|
1446
1450
|
}
|
|
1447
1451
|
|
|
1448
1452
|
saveBuffer(filepath) {
|
|
1449
|
-
if(this.fileBuffer[filepath]) {
|
|
1453
|
+
if (this.fileBuffer[filepath]) {
|
|
1450
1454
|
this.fileBuffer[filepath].imports = this.imports.concat(this.fileBuffer[filepath].imports);
|
|
1451
1455
|
this.fileBuffer[filepath].usedTypes = this.usedTypes.concat(this.fileBuffer[filepath].usedTypes);
|
|
1452
1456
|
this.fileBuffer[filepath].output = this.output + this.fileBuffer[filepath].output;
|
|
@@ -1498,39 +1502,39 @@ setup(
|
|
|
1498
1502
|
modelNames.push(modelName);
|
|
1499
1503
|
this.emit(`from ._${_snakeCase(mainModelName)} import ${modelName}\n`);
|
|
1500
1504
|
}
|
|
1501
|
-
|
|
1505
|
+
|
|
1502
1506
|
this.emit('\n__all__ = [\n');
|
|
1503
1507
|
this.emit(modelNames.join(',\n '), 2);
|
|
1504
|
-
if(moreExports && moreExports.length > 0) {
|
|
1508
|
+
if (moreExports && moreExports.length > 0) {
|
|
1505
1509
|
this.emit((',\n'));
|
|
1506
1510
|
this.emit(moreExports.join(',\n '), 2);
|
|
1507
1511
|
}
|
|
1508
|
-
|
|
1512
|
+
|
|
1509
1513
|
this.emit('\n]\n');
|
|
1510
1514
|
|
|
1511
1515
|
this.save(path.join(this.modelPath, '__init__.py'));
|
|
1512
1516
|
this.moreExports = [];
|
|
1513
1517
|
}
|
|
1514
1518
|
|
|
1515
|
-
visitFieldsInit(ast, level, modelName, type = 'model', baseErr = false){
|
|
1519
|
+
visitFieldsInit(ast, level, modelName, type = 'model', baseErr = false) {
|
|
1516
1520
|
let node;
|
|
1517
1521
|
this.emit(' def __init__(');
|
|
1518
1522
|
const paramNodes = this.dealExtendFileds(ast);
|
|
1519
|
-
if (!paramNodes.length)
|
|
1523
|
+
if (!paramNodes.length) {
|
|
1520
1524
|
this.emit('self):\n');
|
|
1521
1525
|
this.emit('pass', level + 2);
|
|
1522
1526
|
return;
|
|
1523
1527
|
}
|
|
1524
1528
|
this.emit('\n');
|
|
1525
|
-
this.emit(`self,${
|
|
1529
|
+
this.emit(`self,${this.config.strictModel ? ' *,' : ''}\n`, level + 2);
|
|
1526
1530
|
for (let i = 0; i < paramNodes.length; i++) {
|
|
1527
1531
|
node = paramNodes[i];
|
|
1528
|
-
if(!node.extend) {
|
|
1532
|
+
if (!node.extend) {
|
|
1529
1533
|
let comments = DSL.comment.getFrontComments(this.comments, node.tokenRange[0]);
|
|
1530
1534
|
this.visitComments(comments, level);
|
|
1531
1535
|
}
|
|
1532
1536
|
let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
|
|
1533
|
-
if(param === 'name' && type === 'exception') {
|
|
1537
|
+
if (param === 'name' && type === 'exception') {
|
|
1534
1538
|
continue;
|
|
1535
1539
|
}
|
|
1536
1540
|
this.emit(`${param}: `, level + 2);
|
|
@@ -1538,16 +1542,16 @@ setup(
|
|
|
1538
1542
|
this.emit(' = None,\n');
|
|
1539
1543
|
}
|
|
1540
1544
|
this.emit('):\n', level);
|
|
1541
|
-
|
|
1542
|
-
if(ast.extendFileds && ast.extendFileds.length > 0) {
|
|
1545
|
+
|
|
1546
|
+
if (ast.extendFileds && ast.extendFileds.length > 0) {
|
|
1543
1547
|
this.emit('super().__init__(', level + 2);
|
|
1544
|
-
if(baseErr) {
|
|
1548
|
+
if (baseErr) {
|
|
1545
1549
|
this.emit('{\n');
|
|
1546
1550
|
for (let i = 0; i < ast.extendFileds.length; i++) {
|
|
1547
1551
|
node = ast.extendFileds[i];
|
|
1548
1552
|
let value = _snakeCase(_escape(_name(node.fieldName)));
|
|
1549
1553
|
let key = _avoidKeywords(_escape(_name(node.fieldName)));
|
|
1550
|
-
if(key === 'name' && type === 'exception') {
|
|
1554
|
+
if (key === 'name' && type === 'exception') {
|
|
1551
1555
|
continue;
|
|
1552
1556
|
}
|
|
1553
1557
|
this.emit(`'${key}': ${value},\n`, level + 4);
|
|
@@ -1558,7 +1562,7 @@ setup(
|
|
|
1558
1562
|
for (let i = 0; i < ast.extendFileds.length; i++) {
|
|
1559
1563
|
node = ast.extendFileds[i];
|
|
1560
1564
|
let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
|
|
1561
|
-
if(param === 'name' && type === 'exception') {
|
|
1565
|
+
if (param === 'name' && type === 'exception') {
|
|
1562
1566
|
continue;
|
|
1563
1567
|
}
|
|
1564
1568
|
this.emit(`${param} = ${param},\n`, level + 4);
|
|
@@ -1572,14 +1576,14 @@ setup(
|
|
|
1572
1576
|
assert.equal(ast.type, 'exceptionBody');
|
|
1573
1577
|
this.visitFieldsInit(ast, level, exceptionName, 'exception', this.extendBaseErr(extendOn));
|
|
1574
1578
|
let node;
|
|
1575
|
-
|
|
1579
|
+
|
|
1576
1580
|
this.emit(`self.name = '${exceptionName}Exception'\n`, level + 2);
|
|
1577
1581
|
for (let i = 0; i < ast.nodes.length; i++) {
|
|
1578
1582
|
node = ast.nodes[i];
|
|
1579
1583
|
let comments = DSL.comment.getFrontComments(this.comments, node.tokenRange[0]);
|
|
1580
1584
|
this.visitComments(comments, level);
|
|
1581
1585
|
let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
|
|
1582
|
-
if(param === 'name') {
|
|
1586
|
+
if (param === 'name') {
|
|
1583
1587
|
continue;
|
|
1584
1588
|
}
|
|
1585
1589
|
this.emit(`self.${param} = ${param}\n`, level + 2);
|
|
@@ -1626,7 +1630,7 @@ setup(
|
|
|
1626
1630
|
exceptionNames.push(exceptionName);
|
|
1627
1631
|
this.emit(`from ._${_snakeCase(exceptionName)} import ${exceptionName}Exception\n`);
|
|
1628
1632
|
}
|
|
1629
|
-
|
|
1633
|
+
|
|
1630
1634
|
this.emit('\n__all__ = [\n');
|
|
1631
1635
|
this.emit(exceptionNames.join('Exception,\n '), 2);
|
|
1632
1636
|
this.emit('Exception\n]\n');
|
|
@@ -1658,7 +1662,7 @@ setup(
|
|
|
1658
1662
|
} else {
|
|
1659
1663
|
this.emit('\n');
|
|
1660
1664
|
}
|
|
1661
|
-
} else if (ast.type !== 'expandField'){
|
|
1665
|
+
} else if (ast.type !== 'expandField') {
|
|
1662
1666
|
throw new Error('unimpelemented');
|
|
1663
1667
|
}
|
|
1664
1668
|
}
|
|
@@ -1676,7 +1680,7 @@ setup(
|
|
|
1676
1680
|
} else {
|
|
1677
1681
|
this.emit('\n');
|
|
1678
1682
|
}
|
|
1679
|
-
} else if (ast.type !== 'expandField'){
|
|
1683
|
+
} else if (ast.type !== 'expandField') {
|
|
1680
1684
|
throw new Error('unimpelemented');
|
|
1681
1685
|
}
|
|
1682
1686
|
}
|
|
@@ -1700,10 +1704,10 @@ setup(
|
|
|
1700
1704
|
}
|
|
1701
1705
|
expandFields.push(ast.fields[i]);
|
|
1702
1706
|
}
|
|
1703
|
-
if (expandFields.length !== 0){
|
|
1707
|
+
if (expandFields.length !== 0) {
|
|
1704
1708
|
this.pushImports(`${CORE}Core`);
|
|
1705
1709
|
this.emit(`${CORE}Core.merge({`);
|
|
1706
|
-
if(ast.fields.length !== expandFields.length) {
|
|
1710
|
+
if (ast.fields.length !== expandFields.length) {
|
|
1707
1711
|
this.emit('\n');
|
|
1708
1712
|
}
|
|
1709
1713
|
} else {
|
|
@@ -1714,7 +1718,7 @@ setup(
|
|
|
1714
1718
|
}
|
|
1715
1719
|
|
|
1716
1720
|
if (expandFields.length !== 0) {
|
|
1717
|
-
if(ast.fields.length !== expandFields.length) {
|
|
1721
|
+
if (ast.fields.length !== expandFields.length) {
|
|
1718
1722
|
this.emit('', level);
|
|
1719
1723
|
}
|
|
1720
1724
|
this.emit('}, ');
|
|
@@ -1727,7 +1731,7 @@ setup(
|
|
|
1727
1731
|
} else {
|
|
1728
1732
|
this.emit('}', level);
|
|
1729
1733
|
}
|
|
1730
|
-
|
|
1734
|
+
|
|
1731
1735
|
let comments = DSL.comment.getBetweenComments(this.comments, ast.fields[i - 1].tokenRange[0], ast.tokenRange[1]);
|
|
1732
1736
|
this.visitComments(comments, level + 1);
|
|
1733
1737
|
}
|
|
@@ -1737,16 +1741,18 @@ setup(
|
|
|
1737
1741
|
assert.equal(ast.left.type, 'method_call');
|
|
1738
1742
|
const name = _name(ast.left.id);
|
|
1739
1743
|
const functionName = _avoidKeywords(_snakeCase(name));
|
|
1744
|
+
const sse = ast.notes && ast.notes.find(note => note.note.lexeme === '@sse');
|
|
1745
|
+
const isSSE = sse && sse.arg.value;
|
|
1740
1746
|
if (name.startsWith('$') && this.builtin[name]) {
|
|
1741
1747
|
const method = name.replace('$', '');
|
|
1742
1748
|
this.builtin[name][method](ast, level, ast.isAsync && this.isAsyncFunction);
|
|
1743
1749
|
return;
|
|
1744
|
-
} else if(this.isStaticFunction === false && this.isAsyncFunction && ast.isAsync){
|
|
1745
|
-
this.emit(
|
|
1746
|
-
} else if(this.isStaticFunction === false) {
|
|
1750
|
+
} else if (this.isStaticFunction === false && this.isAsyncFunction && ast.isAsync){
|
|
1751
|
+
this.emit(`${isSSE ? '' : 'await '}self.${functionName}_async`);
|
|
1752
|
+
} else if (this.isStaticFunction === false) {
|
|
1747
1753
|
this.emit(`self.${functionName}`);
|
|
1748
|
-
} else if(ast.isAsync && this.isAsyncFunction) {
|
|
1749
|
-
this.emit(
|
|
1754
|
+
} else if (ast.isAsync && this.isAsyncFunction) {
|
|
1755
|
+
this.emit(`${isSSE ? '' : 'await '}${this.className}.${functionName}_async`);
|
|
1750
1756
|
} else {
|
|
1751
1757
|
const functionName = _snakeCase(name);
|
|
1752
1758
|
this.emit(`${this.className}.${functionName}`);
|
|
@@ -1759,7 +1765,9 @@ setup(
|
|
|
1759
1765
|
assert.equal(ast.left.type, 'instance_call');
|
|
1760
1766
|
const method = _name(ast.left.propertyPath[0]);
|
|
1761
1767
|
const async = ast.isAsync && this.isAsyncFunction;
|
|
1762
|
-
|
|
1768
|
+
const sse = ast.notes && ast.notes.find(note => note.note.lexeme === '@sse');
|
|
1769
|
+
const isSSE = sse && sse.arg.value;
|
|
1770
|
+
if (async && !isSSE) {
|
|
1763
1771
|
this.emit('await ');
|
|
1764
1772
|
}
|
|
1765
1773
|
if (ast.builtinModule && this.builtin[ast.builtinModule] && this.builtin[ast.builtinModule][method]) {
|
|
@@ -1772,7 +1780,7 @@ setup(
|
|
|
1772
1780
|
this.emit(aliasId);
|
|
1773
1781
|
}
|
|
1774
1782
|
this.emit(`.${(_avoidKeywords(_snakeCase(method)))}`);
|
|
1775
|
-
if(async) {
|
|
1783
|
+
if (async) {
|
|
1776
1784
|
this.emit('_async');
|
|
1777
1785
|
}
|
|
1778
1786
|
this.visitArgs(ast.args, level);
|
|
@@ -1792,8 +1800,10 @@ setup(
|
|
|
1792
1800
|
|
|
1793
1801
|
const functionName = _avoidKeywords(_snakeCase(_name(ast.left.propertyPath[0])));
|
|
1794
1802
|
|
|
1803
|
+
const sse = ast.notes && ast.notes.find(note => note.note.lexeme === '@sse');
|
|
1804
|
+
const isSSE = sse && sse.arg.value;
|
|
1795
1805
|
if (ast.isAsync && this.isAsyncFunction) {
|
|
1796
|
-
this.emit(
|
|
1806
|
+
this.emit(`${isSSE ? '' : 'await '}${clientName}.${functionName}_async`);
|
|
1797
1807
|
} else {
|
|
1798
1808
|
this.emit(`${clientName}.${functionName}`);
|
|
1799
1809
|
}
|
|
@@ -1828,18 +1838,18 @@ setup(
|
|
|
1828
1838
|
visitConstruct(ast, level) {
|
|
1829
1839
|
assert.equal(ast.type, 'construct');
|
|
1830
1840
|
const aliasId = _name(ast.aliasId);
|
|
1831
|
-
|
|
1832
|
-
if(this.builtin[aliasId]) {
|
|
1841
|
+
|
|
1842
|
+
if (this.builtin[aliasId]) {
|
|
1833
1843
|
const type = _type(aliasId);
|
|
1834
1844
|
this.pushImports(type);
|
|
1835
1845
|
this.emit(type);
|
|
1836
1846
|
} else {
|
|
1837
1847
|
this.emit(this.getModelName('', aliasId, 'module'));
|
|
1838
1848
|
}
|
|
1839
|
-
|
|
1849
|
+
|
|
1840
1850
|
this.visitArgs(ast.args, level);
|
|
1841
1851
|
}
|
|
1842
|
-
|
|
1852
|
+
|
|
1843
1853
|
|
|
1844
1854
|
visitSuper(ast, level) {
|
|
1845
1855
|
assert.equal(ast.type, 'super');
|
|
@@ -1902,7 +1912,7 @@ setup(
|
|
|
1902
1912
|
} else if (ast.type === 'object') {
|
|
1903
1913
|
this.visitObject(ast, level);
|
|
1904
1914
|
} else if (ast.type === 'variable') {
|
|
1905
|
-
if(ast.inferred &&
|
|
1915
|
+
if (ast.inferred && ast.inferred.type === 'basic' && ast.inferred.name === 'class') {
|
|
1906
1916
|
this.emit(this.getModelName('', _name(ast.id), 'module'));
|
|
1907
1917
|
} else {
|
|
1908
1918
|
this.emit(_avoidKeywords(_snakeCase(_name(ast.id))));
|
|
@@ -1931,7 +1941,7 @@ setup(
|
|
|
1931
1941
|
}
|
|
1932
1942
|
}
|
|
1933
1943
|
const quote = _adaptedQuotes(this.output);
|
|
1934
|
-
this.output =
|
|
1944
|
+
this.output = tmp + `f${quote}${this.output}${quote}`;
|
|
1935
1945
|
} else if (ast.type === 'call') {
|
|
1936
1946
|
// 调用函数
|
|
1937
1947
|
this.visitCall(ast, level);
|
|
@@ -1957,7 +1967,7 @@ setup(
|
|
|
1957
1967
|
this.emit(' * ');
|
|
1958
1968
|
} else if (ast.type === 'and') {
|
|
1959
1969
|
this.emit(' and ');
|
|
1960
|
-
|
|
1970
|
+
// eslint-disable-next-line no-dupe-else-if
|
|
1961
1971
|
} else if (ast.type === 'or') {
|
|
1962
1972
|
this.emit(' or ');
|
|
1963
1973
|
} else if (ast.type === 'lte') {
|
|
@@ -1975,7 +1985,7 @@ setup(
|
|
|
1975
1985
|
}
|
|
1976
1986
|
this.visitExpr(ast.right, level, env);
|
|
1977
1987
|
} else if (ast.type === 'not') {
|
|
1978
|
-
this.emit('not ',level);
|
|
1988
|
+
this.emit('not ', level);
|
|
1979
1989
|
this.visitExpr(ast.expr, level, env);
|
|
1980
1990
|
} else if (ast.type === 'construct_model') {
|
|
1981
1991
|
// 生成实例的初始化赋值
|
|
@@ -2014,7 +2024,7 @@ setup(
|
|
|
2014
2024
|
return item.lexeme;
|
|
2015
2025
|
})].join('.'));
|
|
2016
2026
|
|
|
2017
|
-
if(mainModelName.startsWith('$') && _type(mainModelName)) {
|
|
2027
|
+
if (mainModelName.startsWith('$') && _type(mainModelName)) {
|
|
2018
2028
|
mainModelName = _type(mainModelName);
|
|
2019
2029
|
this.pushImports(mainModelName);
|
|
2020
2030
|
this.emit(mainModelName);
|
|
@@ -2035,7 +2045,7 @@ setup(
|
|
|
2035
2045
|
this.visitModelField(ast.object.fields[i], level, i === ast.object.fields.length - 1);
|
|
2036
2046
|
}
|
|
2037
2047
|
this.emit(')', level);
|
|
2038
|
-
} else{
|
|
2048
|
+
} else {
|
|
2039
2049
|
this.emit(')');
|
|
2040
2050
|
}
|
|
2041
2051
|
|
|
@@ -2114,7 +2124,7 @@ setup(
|
|
|
2114
2124
|
item = ast.items[i];
|
|
2115
2125
|
let comments = DSL.comment.getFrontComments(this.comments, item.tokenRange[0]);
|
|
2116
2126
|
this.visitComments(comments, level);
|
|
2117
|
-
this.emit('', level +2);
|
|
2127
|
+
this.emit('', level + 2);
|
|
2118
2128
|
this.visitExpr(item, level + 2);
|
|
2119
2129
|
if (i < ast.items.length - 1) {
|
|
2120
2130
|
this.emit(',');
|
|
@@ -2137,7 +2147,7 @@ setup(
|
|
|
2137
2147
|
return;
|
|
2138
2148
|
}
|
|
2139
2149
|
this.emit(' ');
|
|
2140
|
-
|
|
2150
|
+
|
|
2141
2151
|
if (ast.needCast) {
|
|
2142
2152
|
this.emit(`${CORE}Core.from_map(\n`);
|
|
2143
2153
|
this.emit('', level + 2);
|
|
@@ -2179,7 +2189,7 @@ setup(
|
|
|
2179
2189
|
this.emit('\n');
|
|
2180
2190
|
this.emit(')', level);
|
|
2181
2191
|
}
|
|
2182
|
-
|
|
2192
|
+
|
|
2183
2193
|
this.emit('\n');
|
|
2184
2194
|
}
|
|
2185
2195
|
|
|
@@ -2225,7 +2235,7 @@ setup(
|
|
|
2225
2235
|
this.emit(':\n');
|
|
2226
2236
|
this.visitStmts(ast.stmts, level + 2);
|
|
2227
2237
|
}
|
|
2228
|
-
|
|
2238
|
+
|
|
2229
2239
|
visitFor(ast, level) {
|
|
2230
2240
|
assert.equal(ast.type, 'for');
|
|
2231
2241
|
// this.emit('\n');
|
|
@@ -2235,8 +2245,8 @@ setup(
|
|
|
2235
2245
|
this.emit('for ', level);
|
|
2236
2246
|
}
|
|
2237
2247
|
|
|
2238
|
-
if (ast.list.inferred && ast.list.inferred.itemType
|
|
2239
|
-
&& ast.list.inferred.itemType.type === 'entry'){
|
|
2248
|
+
if (ast.list.inferred && ast.list.inferred.itemType
|
|
2249
|
+
&& ast.list.inferred.itemType.type === 'entry') {
|
|
2240
2250
|
this.emit('k, v in ');
|
|
2241
2251
|
this.visitExpr(ast.list, level);
|
|
2242
2252
|
} else {
|
|
@@ -2253,11 +2263,11 @@ setup(
|
|
|
2253
2263
|
this.visitExpr(ast.condition);
|
|
2254
2264
|
this.emit(':\n');
|
|
2255
2265
|
this.visitStmts(ast.stmts, level + 2);
|
|
2256
|
-
|
|
2266
|
+
|
|
2257
2267
|
if (ast.elseIfs) {
|
|
2258
2268
|
for (let i = 0; i < ast.elseIfs.length; i++) {
|
|
2259
2269
|
const branch = ast.elseIfs[i];
|
|
2260
|
-
this.emit('elif ',level);
|
|
2270
|
+
this.emit('elif ', level);
|
|
2261
2271
|
this.visitExpr(branch.condition);
|
|
2262
2272
|
this.emit(':\n');
|
|
2263
2273
|
this.visitStmts(branch.stmts, level + 2);
|
|
@@ -2325,7 +2335,7 @@ setup(
|
|
|
2325
2335
|
visitDeclare(ast, level) {
|
|
2326
2336
|
var id = _avoidKeywords(_snakeCase(_name(ast.id)));
|
|
2327
2337
|
this.emit(`${id}`, level);
|
|
2328
|
-
if(id === 'new_full_str'){
|
|
2338
|
+
if (id === 'new_full_str') {
|
|
2329
2339
|
this.emit('');
|
|
2330
2340
|
}
|
|
2331
2341
|
|
|
@@ -2356,7 +2366,7 @@ setup(
|
|
|
2356
2366
|
//empty block's comment
|
|
2357
2367
|
let comments = DSL.comment.getBetweenComments(this.comments, ast.tokenRange[0], ast.tokenRange[1]);
|
|
2358
2368
|
this.visitComments(comments, level);
|
|
2359
|
-
this.emit('pass\n',level);
|
|
2369
|
+
this.emit('pass\n', level);
|
|
2360
2370
|
}
|
|
2361
2371
|
}
|
|
2362
2372
|
|
|
@@ -2396,7 +2406,7 @@ setup(
|
|
|
2396
2406
|
} else {
|
|
2397
2407
|
this.isStaticFunction = false;
|
|
2398
2408
|
}
|
|
2399
|
-
|
|
2409
|
+
|
|
2400
2410
|
this.emit('', level);
|
|
2401
2411
|
|
|
2402
2412
|
this.emit('def ');
|
|
@@ -2409,7 +2419,7 @@ setup(
|
|
|
2409
2419
|
} else {
|
|
2410
2420
|
this.visitParams(ast.params, level, true);
|
|
2411
2421
|
}
|
|
2412
|
-
|
|
2422
|
+
|
|
2413
2423
|
// 返回值类型
|
|
2414
2424
|
this.visitReturnType(ast);
|
|
2415
2425
|
this.emit(':\n');
|
|
@@ -2448,7 +2458,7 @@ setup(
|
|
|
2448
2458
|
this.visitFunctionBody(ast.functionBody, secondLevel);
|
|
2449
2459
|
} else {
|
|
2450
2460
|
let comments = DSL.comment.getFrontComments(this.comments, ast.tokenRange[0]);
|
|
2451
|
-
this.visitComments(comments, level+2);
|
|
2461
|
+
this.visitComments(comments, level + 2);
|
|
2452
2462
|
this.emit('raise Exception(\'Un-implemented\')\n', level + 2);
|
|
2453
2463
|
}
|
|
2454
2464
|
}
|
|
@@ -2461,7 +2471,8 @@ setup(
|
|
|
2461
2471
|
// if (ast.annotation) {
|
|
2462
2472
|
// this.emit(`${_anno(ast.annotation.value)}\n`, level);
|
|
2463
2473
|
// }
|
|
2464
|
-
|
|
2474
|
+
const sse = ast.notes.find(note => note.note.lexeme === '@sse');
|
|
2475
|
+
const isSSE = sse && sse.arg.value;
|
|
2465
2476
|
this.visitAnnotation(ast.annotation, level);
|
|
2466
2477
|
let comments = DSL.comment.getFrontComments(this.comments, ast.tokenRange[0]);
|
|
2467
2478
|
this.visitComments(comments, level);
|
|
@@ -2484,7 +2495,7 @@ setup(
|
|
|
2484
2495
|
this.visitAPIBody(ast.apiBody, secondLevel);
|
|
2485
2496
|
}
|
|
2486
2497
|
this.emit(`_last_request = ${REQUEST}\n`, secondLevel);
|
|
2487
|
-
this.emit(`${RESPONSE} = ${CORE}Core
|
|
2498
|
+
this.emit(`${RESPONSE} = ${CORE}Core.${isSSE ? 'do_sse_action' : 'do_action'}(${REQUEST}`, secondLevel);
|
|
2488
2499
|
if (ast.runtimeBody) {
|
|
2489
2500
|
this.emit(', _runtime');
|
|
2490
2501
|
}
|
|
@@ -2517,7 +2528,7 @@ setup(
|
|
|
2517
2528
|
// temp level
|
|
2518
2529
|
this.visitAPIBody(ast.apiBody, secondLevel);
|
|
2519
2530
|
this.emit(`_last_request = ${REQUEST}\n`, secondLevel);
|
|
2520
|
-
this.emit(`${RESPONSE} = await ${CORE}Core
|
|
2531
|
+
this.emit(`${RESPONSE} = await ${CORE}Core.${isSSE ? 'async_do_sse_action' : 'async_do_action'}(${REQUEST}`, secondLevel);
|
|
2521
2532
|
if (ast.runtimeBody) {
|
|
2522
2533
|
this.emit(', _runtime');
|
|
2523
2534
|
}
|
|
@@ -2559,61 +2570,49 @@ setup(
|
|
|
2559
2570
|
tempOutput += '# This file is auto-generated, don\'t edit it. Thanks.\n';
|
|
2560
2571
|
}
|
|
2561
2572
|
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
this.imports.forEach(ele => {
|
|
2566
|
-
let header = '';
|
|
2567
|
-
if(ele.packageName) {
|
|
2568
|
-
header += `from ${ele.packageName} `;
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
if(ele.className) {
|
|
2572
|
-
header += `import ${ele.className} `;
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
if(ele.aliasName) {
|
|
2576
|
-
header += `as ${ele.aliasName} `;
|
|
2577
|
-
}
|
|
2578
|
-
imports.push(header);
|
|
2573
|
+
this.imports.push({
|
|
2574
|
+
packageName: '__future__',
|
|
2575
|
+
className: 'annotations',
|
|
2579
2576
|
});
|
|
2580
2577
|
|
|
2581
|
-
tempOutput += [...new Set(imports)].join('\n') + '\n';
|
|
2582
|
-
|
|
2583
2578
|
if (this.usedTypes.length > 0) {
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2579
|
+
this.imports.push({
|
|
2580
|
+
packageName: 'typing',
|
|
2581
|
+
className: [...new Set(this.usedTypes)].join(', '),
|
|
2582
|
+
});
|
|
2587
2583
|
}
|
|
2588
2584
|
|
|
2589
|
-
|
|
2585
|
+
const imports = _sortImports(this.imports);
|
|
2586
|
+
|
|
2587
|
+
tempOutput += _importsToString(imports);
|
|
2588
|
+
|
|
2590
2589
|
// 将临时输出插入到 this.output 的开头
|
|
2591
2590
|
this.output = tempOutput + '\n\n' + this.output;
|
|
2592
2591
|
}
|
|
2593
2592
|
|
|
2594
2593
|
modelInitBefore(ast, level) {
|
|
2595
2594
|
let beginToken = 0;
|
|
2596
|
-
if(ast.imports.length > 0) {
|
|
2595
|
+
if (ast.imports.length > 0) {
|
|
2597
2596
|
const lastIndex = ast.imports.length - 1;
|
|
2598
2597
|
beginToken = ast.imports[lastIndex].tokenRange[0];
|
|
2599
2598
|
}
|
|
2600
2599
|
let endToken = 0;
|
|
2601
|
-
if(ast.moduleBody.nodes.length > 0) {
|
|
2600
|
+
if (ast.moduleBody.nodes.length > 0) {
|
|
2602
2601
|
endToken = ast.moduleBody.nodes[0].tokenRange[0];
|
|
2603
2602
|
}
|
|
2604
2603
|
const beginNotes = DSL.note.getNotes(this.notes, beginToken, endToken);
|
|
2605
2604
|
const part = beginNotes.find(note => note.note.lexeme === '@pythonModel');
|
|
2606
|
-
if(part && part.arg.value) {
|
|
2605
|
+
if (part && part.arg.value) {
|
|
2607
2606
|
this.emit(_string(part.arg.value));
|
|
2608
2607
|
}
|
|
2609
2608
|
|
|
2610
|
-
if(part && part.arg.type === 'object') {
|
|
2609
|
+
if (part && part.arg.type === 'object') {
|
|
2611
2610
|
part.arg.fields.map(field => {
|
|
2612
|
-
if(_name(field.fieldName) === 'header') {
|
|
2611
|
+
if (_name(field.fieldName) === 'header') {
|
|
2613
2612
|
this.emit(_string(field.expr.value));
|
|
2614
2613
|
}
|
|
2615
2614
|
|
|
2616
|
-
if(_name(field.fieldName) === 'exports') {
|
|
2615
|
+
if (_name(field.fieldName) === 'exports') {
|
|
2617
2616
|
this.moreExports = field.expr.items.map(item => {
|
|
2618
2617
|
return _string(item.value);
|
|
2619
2618
|
});
|
|
@@ -2624,23 +2623,23 @@ setup(
|
|
|
2624
2623
|
|
|
2625
2624
|
moduleBefore(ast, level) {
|
|
2626
2625
|
let beginToken = 0;
|
|
2627
|
-
if(ast.imports.length > 0) {
|
|
2626
|
+
if (ast.imports.length > 0) {
|
|
2628
2627
|
const lastIndex = ast.imports.length - 1;
|
|
2629
2628
|
beginToken = ast.imports[lastIndex].tokenRange[0];
|
|
2630
2629
|
}
|
|
2631
|
-
let endToken = 0;
|
|
2632
|
-
if(ast.moduleBody.nodes.length > 0) {
|
|
2630
|
+
let endToken = 0;
|
|
2631
|
+
if (ast.moduleBody.nodes.length > 0) {
|
|
2633
2632
|
endToken = ast.moduleBody.nodes[0].tokenRange[0];
|
|
2634
2633
|
}
|
|
2635
2634
|
const beginNotes = DSL.note.getNotes(this.notes, beginToken, endToken);
|
|
2636
2635
|
const part = beginNotes.find(note => note.note.lexeme === '@python');
|
|
2637
|
-
if(part && part.arg.value) {
|
|
2636
|
+
if (part && part.arg.value) {
|
|
2638
2637
|
this.emit(_string(part.arg.value));
|
|
2639
2638
|
}
|
|
2640
2639
|
}
|
|
2641
2640
|
|
|
2642
2641
|
apiBefore(level) {
|
|
2643
|
-
|
|
2642
|
+
|
|
2644
2643
|
this.emit(`class ${this.className}`, level);
|
|
2645
2644
|
if (this.parentModule) {
|
|
2646
2645
|
const aliasId = _name(this.parentModule);
|
|
@@ -2657,8 +2656,8 @@ setup(
|
|
|
2657
2656
|
return this.checkFieldHasModel(fieldValue.fieldItemType || fieldValue.subType);
|
|
2658
2657
|
} else if (fieldValue.fieldType === 'map' || fieldValue.type === 'map') {
|
|
2659
2658
|
return this.checkFieldHasModel(fieldValue.valueType);
|
|
2660
|
-
} else if (fieldValue.type === 'moduleModel' ||
|
|
2661
|
-
|
|
2659
|
+
} else if (fieldValue.type === 'moduleModel' ||
|
|
2660
|
+
(fieldValue.fieldType && fieldValue.fieldType.type === 'moduleModel')) {
|
|
2662
2661
|
return true;
|
|
2663
2662
|
} else if (fieldValue.type === 'subModel') {
|
|
2664
2663
|
return true;
|
|
@@ -2681,15 +2680,15 @@ setup(
|
|
|
2681
2680
|
} else if (obj.fieldItemType.fieldType === 'array') {
|
|
2682
2681
|
// 如果 fieldItemType 仍然是数组
|
|
2683
2682
|
return this.checkFieldItemTypeAllString(obj.fieldItemType);
|
|
2684
|
-
} else if (obj.fieldItemType.valueType && obj.fieldItemType.valueType.lexeme === 'any'){
|
|
2683
|
+
} else if (obj.fieldItemType.valueType && obj.fieldItemType.valueType.lexeme === 'any') {
|
|
2685
2684
|
return true;
|
|
2686
2685
|
}
|
|
2687
2686
|
}
|
|
2688
|
-
if (obj && obj.fieldType ==='map'){
|
|
2687
|
+
if (obj && obj.fieldType === 'map') {
|
|
2689
2688
|
return this.checkFieldItemTypeAllString(obj.valueType);
|
|
2690
2689
|
}
|
|
2691
|
-
if (obj && obj.subType){
|
|
2692
|
-
if (obj.subType.type === 'map'){
|
|
2690
|
+
if (obj && obj.subType) {
|
|
2691
|
+
if (obj.subType.type === 'map') {
|
|
2693
2692
|
return this.checkFieldItemTypeAllString(obj.subType);
|
|
2694
2693
|
}
|
|
2695
2694
|
}
|
|
@@ -2702,7 +2701,7 @@ setup(
|
|
|
2702
2701
|
}
|
|
2703
2702
|
|
|
2704
2703
|
getClassNamespace(pyPath) {
|
|
2705
|
-
if(path.resolve(pyPath).startsWith(path.resolve(this.outputDir))) {
|
|
2704
|
+
if (path.resolve(pyPath).startsWith(path.resolve(this.outputDir))) {
|
|
2706
2705
|
const baseDir = path.join(this.outputDir, path.sep, this.config.package);
|
|
2707
2706
|
pyPath = pyPath.replace(baseDir, '');
|
|
2708
2707
|
}
|
|
@@ -2712,12 +2711,12 @@ setup(
|
|
|
2712
2711
|
|
|
2713
2712
|
let className = this.config.package;
|
|
2714
2713
|
arr.map(key => {
|
|
2715
|
-
if(!key) {
|
|
2714
|
+
if (!key) {
|
|
2716
2715
|
return;
|
|
2717
2716
|
}
|
|
2718
2717
|
className += '.' + key;
|
|
2719
2718
|
});
|
|
2720
|
-
|
|
2719
|
+
|
|
2721
2720
|
return className;
|
|
2722
2721
|
}
|
|
2723
2722
|
|
|
@@ -2740,11 +2739,11 @@ setup(
|
|
|
2740
2739
|
const nameAttr = node.attrs.find((item) => {
|
|
2741
2740
|
return item.attrName.lexeme === 'name';
|
|
2742
2741
|
});
|
|
2743
|
-
return
|
|
2742
|
+
return nameAttr ? _string(nameAttr.attrValue) : _name(node.fieldName);
|
|
2744
2743
|
}
|
|
2745
2744
|
|
|
2746
|
-
getModelName(name, moduleName, type = 'model'){
|
|
2747
|
-
if(type === 'model' && !moduleName) {
|
|
2745
|
+
getModelName(name, moduleName, type = 'model') {
|
|
2746
|
+
if (type === 'model' && !moduleName) {
|
|
2748
2747
|
const aliasName = 'main_models';
|
|
2749
2748
|
this.imports.push({
|
|
2750
2749
|
aliasName,
|
|
@@ -2754,7 +2753,7 @@ setup(
|
|
|
2754
2753
|
return `${aliasName}.${name}`;
|
|
2755
2754
|
}
|
|
2756
2755
|
|
|
2757
|
-
if(type === 'model' && moduleName) {
|
|
2756
|
+
if (type === 'model' && moduleName) {
|
|
2758
2757
|
const { namemespace, models } = this.packageInfo[moduleName];
|
|
2759
2758
|
const aliasName = `${_snakeCase(moduleName.replace(/-/g, ''))}_models`;
|
|
2760
2759
|
this.imports.push({
|
|
@@ -2765,7 +2764,7 @@ setup(
|
|
|
2765
2764
|
return `${aliasName}.${name}`;
|
|
2766
2765
|
}
|
|
2767
2766
|
|
|
2768
|
-
if(type === 'exception' && !moduleName) {
|
|
2767
|
+
if (type === 'exception' && !moduleName) {
|
|
2769
2768
|
const aliasName = 'main_exceptions';
|
|
2770
2769
|
this.imports.push({
|
|
2771
2770
|
aliasName,
|
|
@@ -2775,7 +2774,7 @@ setup(
|
|
|
2775
2774
|
return `${aliasName}.${name}Exception`;
|
|
2776
2775
|
}
|
|
2777
2776
|
|
|
2778
|
-
if(type === 'exception' && moduleName) {
|
|
2777
|
+
if (type === 'exception' && moduleName) {
|
|
2779
2778
|
const { namemespace, exceptions } = this.packageInfo[moduleName];
|
|
2780
2779
|
const aliasName = `${_snakeCase(moduleName.replace(/-/g, ''))}_exceptions`;
|
|
2781
2780
|
this.imports.push({
|
|
@@ -2786,7 +2785,7 @@ setup(
|
|
|
2786
2785
|
return `${aliasName}.${name}Exception`;
|
|
2787
2786
|
}
|
|
2788
2787
|
|
|
2789
|
-
if(type === 'module') {
|
|
2788
|
+
if (type === 'module') {
|
|
2790
2789
|
const {
|
|
2791
2790
|
aliasName,
|
|
2792
2791
|
clientName,
|
|
@@ -2811,7 +2810,7 @@ setup(
|
|
|
2811
2810
|
const moduleAst = this.ast.innerDep.get(aliasId);
|
|
2812
2811
|
const beginNotes = DSL.note.getNotes(moduleAst.notes, 0, moduleAst.moduleBody.nodes[0].tokenRange[0]);
|
|
2813
2812
|
const clientNote = beginNotes.find(note => note.note.lexeme === '@clientName');
|
|
2814
|
-
if(clientNote) {
|
|
2813
|
+
if (clientNote) {
|
|
2815
2814
|
return _string(clientNote.arg.value);
|
|
2816
2815
|
}
|
|
2817
2816
|
return 'Client';
|
|
@@ -2819,30 +2818,30 @@ setup(
|
|
|
2819
2818
|
|
|
2820
2819
|
pushImports(type) {
|
|
2821
2820
|
const pkg = _getImport(type);
|
|
2822
|
-
if(pkg) {
|
|
2821
|
+
if (pkg) {
|
|
2823
2822
|
this.imports.push(pkg);
|
|
2824
2823
|
return;
|
|
2825
2824
|
}
|
|
2826
2825
|
|
|
2827
|
-
if(type === 'sys') {
|
|
2826
|
+
if (type === 'sys') {
|
|
2828
2827
|
this.imports.push({
|
|
2829
2828
|
className: 'sys',
|
|
2830
2829
|
});
|
|
2831
2830
|
}
|
|
2832
2831
|
|
|
2833
|
-
if(type === 'Any'
|
|
2832
|
+
if (type === 'Any') {
|
|
2834
2833
|
this.usedTypes.push('Any');
|
|
2835
2834
|
}
|
|
2836
2835
|
|
|
2837
|
-
if(type === 'array') {
|
|
2836
|
+
if (type === 'array') {
|
|
2838
2837
|
this.usedTypes.push('List');
|
|
2839
2838
|
}
|
|
2840
2839
|
|
|
2841
|
-
if(type === 'map') {
|
|
2840
|
+
if (type === 'map') {
|
|
2842
2841
|
this.usedTypes.push('Dict');
|
|
2843
2842
|
}
|
|
2844
2843
|
|
|
2845
|
-
if(type === 'BinaryIO') {
|
|
2844
|
+
if (type === 'BinaryIO') {
|
|
2846
2845
|
this.usedTypes.push('BinaryIO');
|
|
2847
2846
|
}
|
|
2848
2847
|
|