@darabonba/python-generator 1.2.8 → 1.2.9
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/.github/workflows/ci.yml +30 -0
- package/ChangeLog.md +4 -0
- package/README-CN.md +0 -3
- package/README.md +0 -3
- package/package.json +1 -1
- package/src/generator.js +23 -0
- package/src/langs/common/combinator.js +2 -0
- package/src/langs/python/combinator.js +39 -7
- package/src/langs/python2/combinator.js +32 -0
- package/src/resolver/base.js +10 -0
- package/tests/expected/python2/typedef/setup.py +85 -0
- package/tests/expected/python2/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/python2/typedef/tea_python_tests/client.py +38 -0
- package/tests/expected/python2/typedef/tea_python_tests/models.py +35 -0
- package/tests/expected/python3/typedef/setup.py +77 -0
- package/tests/expected/python3/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/python3/typedef/tea_python_tests/client.py +72 -0
- package/tests/expected/python3/typedef/tea_python_tests/models.py +39 -0
- package/tests/fixtures/typedef/.libraries.json +3 -0
- package/tests/fixtures/typedef/Darafile +61 -0
- package/tests/fixtures/typedef/libraries/alibabacloud-OSS-0.0.1/Darafile +30 -0
- package/tests/fixtures/typedef/libraries/alibabacloud-OSS-0.0.1/oss.dara +6 -0
- package/tests/fixtures/typedef/main.dara +38 -0
- package/tests/python2.tests.js +42 -0
- package/tests/python3.tests.js +42 -0
- package/.travis.yml +0 -9
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [12.x, 14.x, 16.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v2
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
- run: npm install
|
|
29
|
+
- run: npm run ci
|
|
30
|
+
- run: npm run test
|
package/ChangeLog.md
CHANGED
package/README-CN.md
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
# Darabonba Python 生成器
|
|
4
4
|
|
|
5
5
|
[![NPM version][npm-image]][npm-url]
|
|
6
|
-
[![build status][travis-image]][travis-url]
|
|
7
6
|
[![codecov][cov-image]][cov-url]
|
|
8
7
|
[![David deps][david-image]][david-url]
|
|
9
8
|
[![npm download][download-image]][download-url]
|
|
10
9
|
|
|
11
10
|
[npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
|
|
12
11
|
[npm-url]: https://npmjs.org/package/@darabonba/python-generator
|
|
13
|
-
[travis-image]: https://img.shields.io/travis/aliyun/darabonba-python-generator.svg?style=flat-square
|
|
14
|
-
[travis-url]: https://travis-ci.org/aliyun/darabonba-python-generator
|
|
15
12
|
[cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
|
|
16
13
|
[cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
|
|
17
14
|
[david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
|
package/README.md
CHANGED
|
@@ -3,15 +3,12 @@ English | [简体中文](/README-CN.md)
|
|
|
3
3
|
# Darabonba Python Generator
|
|
4
4
|
|
|
5
5
|
[![NPM version][npm-image]][npm-url]
|
|
6
|
-
[![build status][travis-image]][travis-url]
|
|
7
6
|
[![codecov][cov-image]][cov-url]
|
|
8
7
|
[![David deps][david-image]][david-url]
|
|
9
8
|
[![npm download][download-image]][download-url]
|
|
10
9
|
|
|
11
10
|
[npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
|
|
12
11
|
[npm-url]: https://npmjs.org/package/@darabonba/python-generator
|
|
13
|
-
[travis-image]: https://img.shields.io/travis/aliyun/darabonba-python-generator.svg?style=flat-square
|
|
14
|
-
[travis-url]: https://travis-ci.org/aliyun/darabonba-python-generator
|
|
15
12
|
[cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
|
|
16
13
|
[cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
|
|
17
14
|
[david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
|
package/package.json
CHANGED
package/src/generator.js
CHANGED
|
@@ -14,11 +14,18 @@ class Generator {
|
|
|
14
14
|
throw new Error('`option.outputDir` should not empty');
|
|
15
15
|
}
|
|
16
16
|
this.lang = lang;
|
|
17
|
+
this.typedef = meta[lang] && meta[lang].typedef ? meta[lang].typedef : {};
|
|
17
18
|
this.initConfig(meta);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
visit(ast) {
|
|
21
22
|
this.imports = this.resolveImports(ast);
|
|
23
|
+
this.imports.typedef = this.typedef;
|
|
24
|
+
Object.keys(this.typedef).forEach((def) => {
|
|
25
|
+
if (this.typedef[def].package && !this.imports.requirePackage.includes(this.typedef[def].package)) {
|
|
26
|
+
this.imports.requirePackage.push(this.typedef[def].package);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
22
29
|
const objects = [];
|
|
23
30
|
|
|
24
31
|
// combine client code
|
|
@@ -120,6 +127,7 @@ class Generator {
|
|
|
120
127
|
let thirdPackageModel = {};
|
|
121
128
|
let thirdPackageClient = {};
|
|
122
129
|
let thirdPackageClientAlias = {};
|
|
130
|
+
let importsTypedef = {};
|
|
123
131
|
|
|
124
132
|
if (imports.length > 0) {
|
|
125
133
|
const lockPath = path.join(this.config.pkgDir, '.libraries.json');
|
|
@@ -158,6 +166,20 @@ class Generator {
|
|
|
158
166
|
modelDir = daraMeta[this.lang].modelDirName
|
|
159
167
|
? daraMeta[this.lang].modelDirName
|
|
160
168
|
: this.config.model.dir;
|
|
169
|
+
if (daraMeta[this.lang].typedef) {
|
|
170
|
+
importsTypedef[aliasId] = {};
|
|
171
|
+
const moduleTypedef = daraMeta[this.lang].typedef;
|
|
172
|
+
Object.keys(moduleTypedef || {}).forEach((types) => {
|
|
173
|
+
if (!importsTypedef[aliasId][types]) {
|
|
174
|
+
importsTypedef[aliasId][types] = {};
|
|
175
|
+
}
|
|
176
|
+
importsTypedef[aliasId][types].import = moduleTypedef[types].import;
|
|
177
|
+
importsTypedef[aliasId][types].type = moduleTypedef[types].type;
|
|
178
|
+
if (!requirePackage.includes(moduleTypedef[types].package)) {
|
|
179
|
+
requirePackage.push(moduleTypedef[types].package);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
161
183
|
} else {
|
|
162
184
|
packageName = daraMeta.name;
|
|
163
185
|
clientName = this.config.clientName;
|
|
@@ -197,6 +219,7 @@ class Generator {
|
|
|
197
219
|
thirdPackageClient,
|
|
198
220
|
thirdPackageClientAlias,
|
|
199
221
|
thirdPackageModel,
|
|
222
|
+
importsTypedef,
|
|
200
223
|
};
|
|
201
224
|
}
|
|
202
225
|
}
|
|
@@ -36,6 +36,8 @@ class BaseCombinator {
|
|
|
36
36
|
this.thirdPackageClient = imports.thirdPackageClient;
|
|
37
37
|
this.thirdPackageClientAlias = imports.thirdPackageClientAlias;
|
|
38
38
|
this.thirdPackageModel = imports.thirdPackageModel;
|
|
39
|
+
this.typedef = imports.typedef;
|
|
40
|
+
this.importsTypedef = imports.importsTypedef;
|
|
39
41
|
|
|
40
42
|
_config(this.config);
|
|
41
43
|
}
|
|
@@ -202,6 +202,38 @@ class Combinator extends CombinatorBase {
|
|
|
202
202
|
return resultName;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
addTypedefInclude(typeName) {
|
|
206
|
+
let accessPath = typeName.split('.');
|
|
207
|
+
let importName = '';
|
|
208
|
+
let fromName = '';
|
|
209
|
+
let typedefModule = {};
|
|
210
|
+
if (accessPath.length === 2) {
|
|
211
|
+
if (this.importsTypedef[accessPath[0]] && this.importsTypedef[accessPath[0]][accessPath[1]]) {
|
|
212
|
+
typedefModule = this.importsTypedef[accessPath[0]][accessPath[1]];
|
|
213
|
+
}
|
|
214
|
+
} else if (accessPath.length === 1 && this.typedef[accessPath[0]]) {
|
|
215
|
+
typedefModule = this.typedef[accessPath[0]];
|
|
216
|
+
}
|
|
217
|
+
if (typedefModule.import || typedefModule.package) {
|
|
218
|
+
if (typedefModule.import) {
|
|
219
|
+
fromName = typedefModule.import;
|
|
220
|
+
}
|
|
221
|
+
if (typedefModule.type) {
|
|
222
|
+
importName = typedefModule.type;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let existResult = this.includeList.some(item => item.import === importName && item.from === fromName);
|
|
227
|
+
if (!existResult) {
|
|
228
|
+
this.includeList.push({
|
|
229
|
+
'from': fromName,
|
|
230
|
+
'import': importName,
|
|
231
|
+
'alias': '',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return typedefModule.type || typeName;
|
|
235
|
+
}
|
|
236
|
+
|
|
205
237
|
simpleImport(imp, from = null) {
|
|
206
238
|
let existResult = this.includeList.some(item => {
|
|
207
239
|
if (item.import === imp && item.from === from) {
|
|
@@ -213,7 +245,7 @@ class Combinator extends CombinatorBase {
|
|
|
213
245
|
from: from,
|
|
214
246
|
import: imp
|
|
215
247
|
});
|
|
216
|
-
}
|
|
248
|
+
}
|
|
217
249
|
}
|
|
218
250
|
|
|
219
251
|
combine(objectArr = []) {
|
|
@@ -402,7 +434,7 @@ class Combinator extends CombinatorBase {
|
|
|
402
434
|
} else if (obj.objectType === 'model' || !this.config.typeMap[obj] && !this.thirdPackageNamespace[obj]) {
|
|
403
435
|
if (_type(obj) === target) {
|
|
404
436
|
return true;
|
|
405
|
-
}
|
|
437
|
+
}
|
|
406
438
|
}
|
|
407
439
|
return false;
|
|
408
440
|
}
|
|
@@ -916,7 +948,7 @@ class Combinator extends CombinatorBase {
|
|
|
916
948
|
this.levelDown();
|
|
917
949
|
}
|
|
918
950
|
|
|
919
|
-
emitNotes(emitter, notes) {}
|
|
951
|
+
emitNotes(emitter, notes) { }
|
|
920
952
|
|
|
921
953
|
emitConstruct(emitter, construct, props, isModule = false) {
|
|
922
954
|
if (construct.params.length + props.length > 0) {
|
|
@@ -950,7 +982,7 @@ class Combinator extends CombinatorBase {
|
|
|
950
982
|
} else {
|
|
951
983
|
emitter.emitln(`${_name(prop.name)}: ${typeHints} = None,`, this.level);
|
|
952
984
|
}
|
|
953
|
-
|
|
985
|
+
|
|
954
986
|
}
|
|
955
987
|
});
|
|
956
988
|
}
|
|
@@ -1200,7 +1232,7 @@ class Combinator extends CombinatorBase {
|
|
|
1200
1232
|
let importList = this.includeList.filter(node => !node.from && node.import);
|
|
1201
1233
|
let aliasList = this.includeList.filter(node => node.from && node.alias);
|
|
1202
1234
|
let list = this.includeList.filter(node => node.from && !node.alias);
|
|
1203
|
-
|
|
1235
|
+
|
|
1204
1236
|
let from = {};
|
|
1205
1237
|
let fromList = [];
|
|
1206
1238
|
|
|
@@ -1489,7 +1521,7 @@ class Combinator extends CombinatorBase {
|
|
|
1489
1521
|
if (item instanceof AnnotationItem) {
|
|
1490
1522
|
if (item.mode === 'single') {
|
|
1491
1523
|
emit.emit(`# ${item.content}`, this.level);
|
|
1492
|
-
}
|
|
1524
|
+
}
|
|
1493
1525
|
tmp.push(emit.output);
|
|
1494
1526
|
return true;
|
|
1495
1527
|
}
|
|
@@ -1761,7 +1793,7 @@ class Combinator extends CombinatorBase {
|
|
|
1761
1793
|
const quote = this._adaptedQuotes(behavior.key, emitter);
|
|
1762
1794
|
emitter.emit(`${emit.output}[${quote}${behavior.key}${quote}] = `, this.level);
|
|
1763
1795
|
}
|
|
1764
|
-
|
|
1796
|
+
|
|
1765
1797
|
this.grammerValue(emitter, behavior.value);
|
|
1766
1798
|
emitter.emitln('');
|
|
1767
1799
|
}
|
|
@@ -198,6 +198,38 @@ class Combinator extends CombinatorBase {
|
|
|
198
198
|
return resultName;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
addTypedefInclude(typeName) {
|
|
202
|
+
let accessPath = typeName.split('.');
|
|
203
|
+
let importName = '';
|
|
204
|
+
let fromName = '';
|
|
205
|
+
let typedefModule = {};
|
|
206
|
+
if (accessPath.length === 2) {
|
|
207
|
+
if (this.importsTypedef[accessPath[0]] && this.importsTypedef[accessPath[0]][accessPath[1]]) {
|
|
208
|
+
typedefModule = this.importsTypedef[accessPath[0]][accessPath[1]];
|
|
209
|
+
}
|
|
210
|
+
} else if (accessPath.length === 1 && this.typedef[accessPath[0]]) {
|
|
211
|
+
typedefModule = this.typedef[accessPath[0]];
|
|
212
|
+
}
|
|
213
|
+
if (typedefModule.import || typedefModule.package) {
|
|
214
|
+
if (typedefModule.import) {
|
|
215
|
+
fromName = typedefModule.import;
|
|
216
|
+
}
|
|
217
|
+
if (typedefModule.type) {
|
|
218
|
+
importName = typedefModule.type;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let existResult = this.includeList.some(item => item.import === importName && item.from === fromName);
|
|
223
|
+
if (!existResult) {
|
|
224
|
+
this.includeList.push({
|
|
225
|
+
'from': fromName,
|
|
226
|
+
'import': importName,
|
|
227
|
+
'alias': '',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return typedefModule.type || typeName;
|
|
231
|
+
}
|
|
232
|
+
|
|
201
233
|
combine(objectArr = []) {
|
|
202
234
|
super.combine(objectArr);
|
|
203
235
|
this.config.dir = this.config.outputDir + '/' + this.config.package + '/';
|
package/src/resolver/base.js
CHANGED
|
@@ -162,6 +162,9 @@ class BaseResolver {
|
|
|
162
162
|
} else if (typeNode.idType === 'module') {
|
|
163
163
|
typeInfo['lexeme'] = this.combinator.addInclude(typeNode.lexeme);
|
|
164
164
|
return typeInfo;
|
|
165
|
+
} else if (typeNode.idType === 'typedef') {
|
|
166
|
+
typeInfo['lexeme'] = this.combinator.addTypedefInclude(typeNode.lexeme);
|
|
167
|
+
return typeInfo;
|
|
165
168
|
} else if (typeNode.idType === 'builtin_model') {
|
|
166
169
|
typeInfo['objectType'] = 'builtin_model';
|
|
167
170
|
return this.combinator.addInclude(typeNode.lexeme);
|
|
@@ -213,6 +216,13 @@ class BaseResolver {
|
|
|
213
216
|
typeInfo['objectType'] = 'model';
|
|
214
217
|
typeInfo['lexeme'] = this.combinator.addModelInclude(tmp.join('.'));
|
|
215
218
|
return typeInfo;
|
|
219
|
+
} else if (typeNode.type === 'moduleTypedef') {
|
|
220
|
+
let tmp = [];
|
|
221
|
+
typeNode.path.forEach(item => {
|
|
222
|
+
tmp.push(item.lexeme);
|
|
223
|
+
});
|
|
224
|
+
typeInfo['lexeme'] = this.combinator.addTypedefInclude(tmp.join('.'));
|
|
225
|
+
return typeInfo;
|
|
216
226
|
} else if (typeNode.type === 'subModel') {
|
|
217
227
|
let tmp = [];
|
|
218
228
|
typeNode.path.forEach(item => {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
or more contributor license agreements. See the NOTICE file
|
|
5
|
+
distributed with this work for additional information
|
|
6
|
+
regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
to you under the Apache License, Version 2.0 (the
|
|
8
|
+
"License"); you may not use this file except in compliance
|
|
9
|
+
with the License. You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing,
|
|
14
|
+
software distributed under the License is distributed on an
|
|
15
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, either express or implied. See the License for the
|
|
17
|
+
specific language governing permissions and limitations
|
|
18
|
+
under the License.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
from setuptools import setup, find_packages
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
setup module for tea_python_tests.
|
|
27
|
+
|
|
28
|
+
Created on 28/05/2022
|
|
29
|
+
|
|
30
|
+
@author: Alibaba
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
PACKAGE = "tea_python_tests"
|
|
34
|
+
NAME = "tea_python_tests" or "alibabacloud-package"
|
|
35
|
+
DESCRIPTION = "Generate setup.py"
|
|
36
|
+
AUTHOR = "Alibaba"
|
|
37
|
+
AUTHOR_EMAIL = "sdk-team@alibabacloud.com"
|
|
38
|
+
URL = "https://github.com/"
|
|
39
|
+
VERSION = __import__(PACKAGE).__version__
|
|
40
|
+
REQUIRES = [
|
|
41
|
+
"requests>=2.21.0, <3.0.0",
|
|
42
|
+
"alibabacloud-tea-py2>=0.0.4, <1.0.0"
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
LONG_DESCRIPTION = ''
|
|
46
|
+
|
|
47
|
+
if os.path.exists('./README.md'):
|
|
48
|
+
if sys.version_info.major == 2:
|
|
49
|
+
with open("README.md") as fp:
|
|
50
|
+
LONG_DESCRIPTION = fp.read()
|
|
51
|
+
else:
|
|
52
|
+
with open("README.md", encoding="utf-8") as fp:
|
|
53
|
+
LONG_DESCRIPTION = fp.read()
|
|
54
|
+
|
|
55
|
+
setup(
|
|
56
|
+
name=NAME,
|
|
57
|
+
version=VERSION,
|
|
58
|
+
description=DESCRIPTION,
|
|
59
|
+
long_description=LONG_DESCRIPTION,
|
|
60
|
+
long_description_content_type='text/markdown',
|
|
61
|
+
author=AUTHOR,
|
|
62
|
+
author_email=AUTHOR_EMAIL,
|
|
63
|
+
license="Apache License 2.0",
|
|
64
|
+
url=URL,
|
|
65
|
+
keywords=["tea","python","tests"],
|
|
66
|
+
packages=find_packages(exclude=["tests*"]),
|
|
67
|
+
include_package_data=True,
|
|
68
|
+
platforms="any",
|
|
69
|
+
install_requires=REQUIRES,
|
|
70
|
+
classifiers=(
|
|
71
|
+
"Development Status :: 4 - Beta",
|
|
72
|
+
"Intended Audience :: Developers",
|
|
73
|
+
"License :: OSI Approved :: Apache Software License",
|
|
74
|
+
"Programming Language :: Python",
|
|
75
|
+
"Programming Language :: Python :: 2",
|
|
76
|
+
"Programming Language :: Python :: 2.7",
|
|
77
|
+
"Programming Language :: Python :: 3",
|
|
78
|
+
"Programming Language :: Python :: 3.4",
|
|
79
|
+
"Programming Language :: Python :: 3.5",
|
|
80
|
+
"Programming Language :: Python :: 3.6",
|
|
81
|
+
"Programming Language :: Python :: 3.7",
|
|
82
|
+
"Programming Language :: Python :: 3.8",
|
|
83
|
+
"Topic :: Software Development"
|
|
84
|
+
)
|
|
85
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from __future__ import unicode_literals
|
|
4
|
+
|
|
5
|
+
from requests import Request
|
|
6
|
+
from Tea.model import TeaModel
|
|
7
|
+
from Source.source_client import SourceClient
|
|
8
|
+
|
|
9
|
+
from tea_python_tests import models as main_models
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Client(object):
|
|
13
|
+
_vid = None # type: Request
|
|
14
|
+
_model = None # type: TeaModel
|
|
15
|
+
|
|
16
|
+
def __init__(self, request, model):
|
|
17
|
+
self._vid = request
|
|
18
|
+
self._model = model
|
|
19
|
+
|
|
20
|
+
def main(self, test_1, test_2):
|
|
21
|
+
oss = SourceClient(test_1)
|
|
22
|
+
m = main_models.M(
|
|
23
|
+
a=test_1,
|
|
24
|
+
b=test_2
|
|
25
|
+
)
|
|
26
|
+
self._vid = test_1
|
|
27
|
+
self._model = test_2
|
|
28
|
+
|
|
29
|
+
def test_http_request(self, req):
|
|
30
|
+
return self.test_http_request_with('test', req)
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def test_http_request_with(method, req):
|
|
34
|
+
raise Exception('Un-implemented')
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def test_http_header(method, headers):
|
|
38
|
+
raise Exception('Un-implemented')
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from Tea.model import TeaModel
|
|
4
|
+
from requests import Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class M(TeaModel):
|
|
8
|
+
def __init__(self, a=None, b=None):
|
|
9
|
+
self.a = a # type: Request
|
|
10
|
+
self.b = b # type: TeaModel
|
|
11
|
+
|
|
12
|
+
def validate(self):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
def to_map(self):
|
|
16
|
+
_map = super(M, self).to_map()
|
|
17
|
+
if _map is not None:
|
|
18
|
+
return _map
|
|
19
|
+
|
|
20
|
+
result = dict()
|
|
21
|
+
if self.a is not None:
|
|
22
|
+
result['a'] = self.a
|
|
23
|
+
if self.b is not None:
|
|
24
|
+
result['b'] = self.b
|
|
25
|
+
return result
|
|
26
|
+
|
|
27
|
+
def from_map(self, m=None):
|
|
28
|
+
m = m or dict()
|
|
29
|
+
if m.get('a') is not None:
|
|
30
|
+
self.a = m.get('a')
|
|
31
|
+
if m.get('b') is not None:
|
|
32
|
+
self.b = m.get('b')
|
|
33
|
+
return self
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
or more contributor license agreements. See the NOTICE file
|
|
5
|
+
distributed with this work for additional information
|
|
6
|
+
regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
to you under the Apache License, Version 2.0 (the
|
|
8
|
+
"License"); you may not use this file except in compliance
|
|
9
|
+
with the License. You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing,
|
|
14
|
+
software distributed under the License is distributed on an
|
|
15
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, either express or implied. See the License for the
|
|
17
|
+
specific language governing permissions and limitations
|
|
18
|
+
under the License.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
from setuptools import setup, find_packages
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
setup module for tea_python_tests.
|
|
26
|
+
|
|
27
|
+
Created on 28/05/2022
|
|
28
|
+
|
|
29
|
+
@author: Alibaba
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
PACKAGE = "tea_python_tests"
|
|
33
|
+
NAME = "tea_python_tests" or "alibabacloud-package"
|
|
34
|
+
DESCRIPTION = "Generate setup.py"
|
|
35
|
+
AUTHOR = "Alibaba"
|
|
36
|
+
AUTHOR_EMAIL = "sdk-team@alibabacloud.com"
|
|
37
|
+
URL = "https://github.com/"
|
|
38
|
+
VERSION = __import__(PACKAGE).__version__
|
|
39
|
+
REQUIRES = [
|
|
40
|
+
"requests>=2.21.0, <3.0.0",
|
|
41
|
+
"alibabacloud-tea>=0.2.9, <1.0.0"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
LONG_DESCRIPTION = ''
|
|
45
|
+
if os.path.exists('./README.md'):
|
|
46
|
+
with open("README.md", encoding='utf-8') as fp:
|
|
47
|
+
LONG_DESCRIPTION = fp.read()
|
|
48
|
+
|
|
49
|
+
setup(
|
|
50
|
+
name=NAME,
|
|
51
|
+
version=VERSION,
|
|
52
|
+
description=DESCRIPTION,
|
|
53
|
+
long_description=LONG_DESCRIPTION,
|
|
54
|
+
long_description_content_type='text/markdown',
|
|
55
|
+
author=AUTHOR,
|
|
56
|
+
author_email=AUTHOR_EMAIL,
|
|
57
|
+
license="Apache License 2.0",
|
|
58
|
+
url=URL,
|
|
59
|
+
keywords=["tea","python","tests"],
|
|
60
|
+
packages=find_packages(exclude=["tests*"]),
|
|
61
|
+
include_package_data=True,
|
|
62
|
+
platforms="any",
|
|
63
|
+
install_requires=REQUIRES,
|
|
64
|
+
python_requires=">=3.6",
|
|
65
|
+
classifiers=(
|
|
66
|
+
"Development Status :: 4 - Beta",
|
|
67
|
+
"Intended Audience :: Developers",
|
|
68
|
+
"License :: OSI Approved :: Apache Software License",
|
|
69
|
+
"Programming Language :: Python",
|
|
70
|
+
"Programming Language :: Python :: 3",
|
|
71
|
+
"Programming Language :: Python :: 3.6",
|
|
72
|
+
'Programming Language :: Python :: 3.7',
|
|
73
|
+
'Programming Language :: Python :: 3.8',
|
|
74
|
+
'Programming Language :: Python :: 3.9',
|
|
75
|
+
"Topic :: Software Development"
|
|
76
|
+
)
|
|
77
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from requests import Request, Response
|
|
4
|
+
from Tea.model import TeaModel
|
|
5
|
+
from Source.source_client import SourceClient
|
|
6
|
+
|
|
7
|
+
from tea_python_tests import models as main_models
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Client:
|
|
11
|
+
_vid: Request = None
|
|
12
|
+
_model: TeaModel = None
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
request: Request,
|
|
17
|
+
model: TeaModel,
|
|
18
|
+
):
|
|
19
|
+
self._vid = request
|
|
20
|
+
self._model = model
|
|
21
|
+
|
|
22
|
+
def main(
|
|
23
|
+
self,
|
|
24
|
+
test_1: Request,
|
|
25
|
+
test_2: TeaModel,
|
|
26
|
+
) -> None:
|
|
27
|
+
oss = SourceClient(test_1)
|
|
28
|
+
m = main_models.M(
|
|
29
|
+
a=test_1,
|
|
30
|
+
b=test_2
|
|
31
|
+
)
|
|
32
|
+
self._vid = test_1
|
|
33
|
+
self._model = test_2
|
|
34
|
+
|
|
35
|
+
async def main_async(
|
|
36
|
+
self,
|
|
37
|
+
test_1: Request,
|
|
38
|
+
test_2: TeaModel,
|
|
39
|
+
) -> None:
|
|
40
|
+
oss = SourceClient(test_1)
|
|
41
|
+
m = main_models.M(
|
|
42
|
+
a=test_1,
|
|
43
|
+
b=test_2
|
|
44
|
+
)
|
|
45
|
+
self._vid = test_1
|
|
46
|
+
self._model = test_2
|
|
47
|
+
|
|
48
|
+
def test_http_request(
|
|
49
|
+
self,
|
|
50
|
+
req: Request,
|
|
51
|
+
) -> Response:
|
|
52
|
+
return self.test_http_request_with('test', req)
|
|
53
|
+
|
|
54
|
+
async def test_http_request_async(
|
|
55
|
+
self,
|
|
56
|
+
req: Request,
|
|
57
|
+
) -> Response:
|
|
58
|
+
return self.test_http_request_with('test', req)
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def test_http_request_with(
|
|
62
|
+
method: str,
|
|
63
|
+
req: Request,
|
|
64
|
+
) -> Response:
|
|
65
|
+
raise Exception('Un-implemented')
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def test_http_header(
|
|
69
|
+
method: str,
|
|
70
|
+
headers: Dict[str, Any],
|
|
71
|
+
) -> Response:
|
|
72
|
+
raise Exception('Un-implemented')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from Tea.model import TeaModel
|
|
4
|
+
from requests import Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class M(TeaModel):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
a: Request = None,
|
|
11
|
+
b: TeaModel = None,
|
|
12
|
+
):
|
|
13
|
+
self.a = a
|
|
14
|
+
self.b = b
|
|
15
|
+
|
|
16
|
+
def validate(self):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
def to_map(self):
|
|
20
|
+
_map = super().to_map()
|
|
21
|
+
if _map is not None:
|
|
22
|
+
return _map
|
|
23
|
+
|
|
24
|
+
result = dict()
|
|
25
|
+
if self.a is not None:
|
|
26
|
+
result['a'] = self.a
|
|
27
|
+
if self.b is not None:
|
|
28
|
+
result['b'] = self.b
|
|
29
|
+
return result
|
|
30
|
+
|
|
31
|
+
def from_map(self, m: dict = None):
|
|
32
|
+
m = m or dict()
|
|
33
|
+
if m.get('a') is not None:
|
|
34
|
+
self.a = m.get('a')
|
|
35
|
+
if m.get('b') is not None:
|
|
36
|
+
self.b = m.get('b')
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scope": "darabonba",
|
|
3
|
+
"name": "main",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "./main.dara",
|
|
6
|
+
"libraries": {
|
|
7
|
+
"OSS": "alibabacloud:OSS:*"
|
|
8
|
+
},
|
|
9
|
+
"python": {
|
|
10
|
+
"package": "tea_python_tests",
|
|
11
|
+
"clientName": "client",
|
|
12
|
+
"typedef": {
|
|
13
|
+
"HttpResponse": {
|
|
14
|
+
"import": "requests",
|
|
15
|
+
"type": "Response",
|
|
16
|
+
"package": "requests:2.21.0"
|
|
17
|
+
},
|
|
18
|
+
"HttpHeader": {
|
|
19
|
+
"import": null,
|
|
20
|
+
"type": "Dict[str, Any]",
|
|
21
|
+
"package": null
|
|
22
|
+
},
|
|
23
|
+
"TeaModel": {
|
|
24
|
+
"import": "Tea.model",
|
|
25
|
+
"type": "TeaModel",
|
|
26
|
+
"package": "alibabacloud-tea:0.2.9"
|
|
27
|
+
},
|
|
28
|
+
"TeaException": {
|
|
29
|
+
"import": "Tea.exceptions",
|
|
30
|
+
"type": "TeaException",
|
|
31
|
+
"package": "alibabacloud-tea:0.2.9"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"python2": {
|
|
36
|
+
"package": "tea_python_tests",
|
|
37
|
+
"clientName": "client",
|
|
38
|
+
"typedef": {
|
|
39
|
+
"HttpResponse": {
|
|
40
|
+
"import": "requests",
|
|
41
|
+
"type": "Response",
|
|
42
|
+
"package": "requests:2.21.0"
|
|
43
|
+
},
|
|
44
|
+
"HttpHeader": {
|
|
45
|
+
"import": null,
|
|
46
|
+
"type": "Dict[str, Any]",
|
|
47
|
+
"package": null
|
|
48
|
+
},
|
|
49
|
+
"TeaModel": {
|
|
50
|
+
"import": "Tea.model",
|
|
51
|
+
"type": "TeaModel",
|
|
52
|
+
"package": "alibabacloud-tea-py2:0.0.4"
|
|
53
|
+
},
|
|
54
|
+
"TeaException": {
|
|
55
|
+
"import": "Tea.exceptions",
|
|
56
|
+
"type": "TeaException",
|
|
57
|
+
"package": "alibabacloud-tea-py2:0.0.4"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "OSS",
|
|
3
|
+
"main": "./oss.dara",
|
|
4
|
+
"libraries": {},
|
|
5
|
+
"releases": {
|
|
6
|
+
"go": "github.com/aliyun/darabonba-go-generator"
|
|
7
|
+
},
|
|
8
|
+
"python": {
|
|
9
|
+
"package": "Source",
|
|
10
|
+
"clientName": "source_client",
|
|
11
|
+
"typedef": {
|
|
12
|
+
"HttpRequest": {
|
|
13
|
+
"import": "requests",
|
|
14
|
+
"type": "Request",
|
|
15
|
+
"package": "requests:2.21.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"python2": {
|
|
20
|
+
"package": "Source",
|
|
21
|
+
"clientName": "source_client",
|
|
22
|
+
"typedef": {
|
|
23
|
+
"HttpRequest": {
|
|
24
|
+
"import": "requests",
|
|
25
|
+
"type": "Request",
|
|
26
|
+
"package": "requests:2.21.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import OSS
|
|
2
|
+
|
|
3
|
+
typedef HttpResponse;
|
|
4
|
+
typedef HttpHeader;
|
|
5
|
+
typedef TeaModel;
|
|
6
|
+
// useless
|
|
7
|
+
typedef TeaException;
|
|
8
|
+
|
|
9
|
+
type @vid=OSS.HttpRequest;
|
|
10
|
+
type @model=TeaModel;
|
|
11
|
+
|
|
12
|
+
init(request: OSS.HttpRequest, model: TeaModel){
|
|
13
|
+
@vid = request;
|
|
14
|
+
@model = model;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model M {
|
|
18
|
+
a?: OSS.HttpRequest,
|
|
19
|
+
b?: TeaModel
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function main(test1: OSS.HttpRequest, test2: TeaModel) : void {
|
|
23
|
+
var oss = new OSS(test1);
|
|
24
|
+
var m = new M {
|
|
25
|
+
a = test1,
|
|
26
|
+
b = test2
|
|
27
|
+
};
|
|
28
|
+
@vid = test1;
|
|
29
|
+
@model = test2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function testHttpRequest(req: OSS.HttpRequest): HttpResponse {
|
|
33
|
+
return testHttpRequestWith("test", req);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static function testHttpRequestWith(method: string, req: OSS.HttpRequest): HttpResponse
|
|
37
|
+
|
|
38
|
+
static function testHttpHeader(method: string, headers: HttpHeader): HttpResponse
|
package/tests/python2.tests.js
CHANGED
|
@@ -228,4 +228,46 @@ describe('Python Generator', function () {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
|
+
it('typedef should ok', function () {
|
|
232
|
+
check('typedef', [
|
|
233
|
+
'tea_python_tests/client.py',
|
|
234
|
+
'tea_python_tests/models.py'
|
|
235
|
+
],
|
|
236
|
+
{
|
|
237
|
+
python2: {
|
|
238
|
+
package: 'tea_python_tests',
|
|
239
|
+
clientName: 'client',
|
|
240
|
+
packageInfo: {
|
|
241
|
+
name: 'tea_python_tests',
|
|
242
|
+
desc: 'Generate setup.py',
|
|
243
|
+
github: 'https://github.com/',
|
|
244
|
+
author: 'Alibaba',
|
|
245
|
+
email: 'sdk-team@alibabacloud.com'
|
|
246
|
+
},
|
|
247
|
+
typedef: {
|
|
248
|
+
HttpResponse: {
|
|
249
|
+
import: 'requests',
|
|
250
|
+
type: 'Response',
|
|
251
|
+
package: 'requests:2.21.0'
|
|
252
|
+
},
|
|
253
|
+
HttpHeader: {
|
|
254
|
+
import: null,
|
|
255
|
+
type: 'Dict[str, Any]',
|
|
256
|
+
package: null
|
|
257
|
+
},
|
|
258
|
+
TeaModel: {
|
|
259
|
+
import: 'Tea.model',
|
|
260
|
+
type: 'TeaModel',
|
|
261
|
+
package: 'alibabacloud-tea-py2:0.0.4'
|
|
262
|
+
},
|
|
263
|
+
TeaException: {
|
|
264
|
+
import: 'Tea.exceptions',
|
|
265
|
+
type: 'TeaException',
|
|
266
|
+
package: 'alibabacloud-tea-py2:0.0.4'
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
});
|
|
272
|
+
});
|
|
231
273
|
});
|
package/tests/python3.tests.js
CHANGED
|
@@ -228,4 +228,46 @@ describe('Python Generator', function () {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
|
+
|
|
232
|
+
it('typedef should ok', function () {
|
|
233
|
+
check('typedef', [
|
|
234
|
+
'tea_python_tests/client.py',
|
|
235
|
+
'tea_python_tests/models.py'
|
|
236
|
+
],
|
|
237
|
+
{
|
|
238
|
+
python: {
|
|
239
|
+
package: 'tea_python_tests',
|
|
240
|
+
clientName: 'client',
|
|
241
|
+
packageInfo: {
|
|
242
|
+
name: 'tea_python_tests',
|
|
243
|
+
desc: 'Generate setup.py',
|
|
244
|
+
github: 'https://github.com/',
|
|
245
|
+
author: 'Alibaba',
|
|
246
|
+
email: 'sdk-team@alibabacloud.com'
|
|
247
|
+
},
|
|
248
|
+
typedef: {
|
|
249
|
+
HttpResponse: {
|
|
250
|
+
import: 'requests',
|
|
251
|
+
type: 'Response',
|
|
252
|
+
package: 'requests:2.21.0'
|
|
253
|
+
},
|
|
254
|
+
HttpHeader: {
|
|
255
|
+
import: null,
|
|
256
|
+
type: 'Dict[str, Any]',
|
|
257
|
+
package: null
|
|
258
|
+
},
|
|
259
|
+
TeaModel: {
|
|
260
|
+
import: 'Tea.model',
|
|
261
|
+
type: 'TeaModel',
|
|
262
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
263
|
+
},
|
|
264
|
+
TeaException: {
|
|
265
|
+
import: 'Tea.exceptions',
|
|
266
|
+
type: 'TeaException',
|
|
267
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
231
273
|
});
|