@darabonba/python-generator 1.2.15 → 1.2.16
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/package.json +1 -1
- package/src/generator.js +2 -0
- package/src/langs/common/combinator.js +1 -0
- package/src/langs/python/combinator.js +2 -1
- package/tests/expected/python2/import/setup.py +1 -1
- package/tests/expected/python2/import/tea_python_tests/__pycache__/__init__.cpython-39.pyc +0 -0
- package/tests/expected/python3/import/setup.py +1 -1
- package/tests/expected/python3/import/tea_python_tests/client.py +1 -0
- package/tests/expected/python3/model/tea_python_tests/client.py +3 -0
- package/tests/expected/python3/model/tea_python_tests/models.py +1 -0
- package/tests/python3.tests.js +14 -2
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/src/generator.js
CHANGED
|
@@ -15,12 +15,14 @@ class Generator {
|
|
|
15
15
|
}
|
|
16
16
|
this.lang = lang;
|
|
17
17
|
this.typedef = meta[lang] && meta[lang].typedef ? meta[lang].typedef : {};
|
|
18
|
+
this.additionalPackage = meta[lang] && meta[lang].additionalPackage ? meta[lang].additionalPackage : [];
|
|
18
19
|
this.initConfig(meta);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
visit(ast) {
|
|
22
23
|
this.imports = this.resolveImports(ast);
|
|
23
24
|
this.imports.typedef = this.typedef;
|
|
25
|
+
this.imports.additionalPackage = this.additionalPackage;
|
|
24
26
|
Object.keys(this.typedef).forEach((def) => {
|
|
25
27
|
if (this.typedef[def].package && !this.imports.requirePackage.includes(this.typedef[def].package)) {
|
|
26
28
|
this.imports.requirePackage.push(this.typedef[def].package);
|
|
@@ -1234,7 +1234,8 @@ class Combinator extends CombinatorBase {
|
|
|
1234
1234
|
let list = this.includeList.filter(node => node.from && !node.alias);
|
|
1235
1235
|
|
|
1236
1236
|
let from = {};
|
|
1237
|
-
let fromList =
|
|
1237
|
+
let fromList = [];
|
|
1238
|
+
fromList = fromList.concat(this.additionalPackage);
|
|
1238
1239
|
|
|
1239
1240
|
list.forEach(item => {
|
|
1240
1241
|
if (!from[item.from]) {
|
|
Binary file
|
package/tests/python3.tests.js
CHANGED
|
@@ -170,7 +170,13 @@ describe('Python Generator', function () {
|
|
|
170
170
|
github: 'https://github.com/',
|
|
171
171
|
author: 'Alibaba',
|
|
172
172
|
email: 'sdk-team@alibabacloud.com'
|
|
173
|
-
}
|
|
173
|
+
},
|
|
174
|
+
additionalPackage: [
|
|
175
|
+
{
|
|
176
|
+
from: '__future__',
|
|
177
|
+
import: 'annotations'
|
|
178
|
+
}
|
|
179
|
+
]
|
|
174
180
|
}
|
|
175
181
|
});
|
|
176
182
|
});
|
|
@@ -195,7 +201,13 @@ describe('Python Generator', function () {
|
|
|
195
201
|
{
|
|
196
202
|
python: {
|
|
197
203
|
package: 'tea_python_tests',
|
|
198
|
-
clientName: 'client'
|
|
204
|
+
clientName: 'client',
|
|
205
|
+
additionalPackage: [
|
|
206
|
+
{
|
|
207
|
+
from: '__future__',
|
|
208
|
+
import: 'annotations'
|
|
209
|
+
}
|
|
210
|
+
]
|
|
199
211
|
}
|
|
200
212
|
});
|
|
201
213
|
});
|