@darabonba/python-generator 2.0.0 → 2.0.2
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/lib/generator.js +43 -29
- package/package.json +1 -1
- package/tests/expected/complex/tea_python_tests/client.py +5 -4
- package/tests/expected/complex/tea_python_tests/models.py +16 -16
- package/tests/expected/model/tea_python_tests/models.py +41 -58
- package/tests/expected/multi/tea_python_tests/model/user.py +3 -0
- package/tests/fixtures/complex/main.dara +1 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +7 -1
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
- package/tests/fixtures/multi/model/user.dara +2 -0
- package/tests/output/complex/tea_python_tests/client.py +5 -4
- package/tests/output/complex/tea_python_tests/models.py +16 -16
- package/tests/output/model/tea_python_tests/models.py +41 -58
- package/tests/output/multi/tea_python_tests/model/user.py +3 -0
- package/src/generator.js +0 -231
- package/src/langs/common/combinator.js +0 -193
- package/src/langs/common/config.js +0 -60
- package/src/langs/common/enum.js +0 -179
- package/src/langs/common/items.js +0 -551
- package/src/langs/common/package_info.js +0 -53
- package/src/langs/python/combinator.js +0 -1898
- package/src/langs/python/config.js +0 -169
- package/src/langs/python/files/.gitignore.tmpl +0 -5
- package/src/langs/python/files/__init__.py.tmpl +0 -1
- package/src/langs/python/files/setup.py.tmpl +0 -74
- package/src/langs/python/package_info.js +0 -78
- package/src/langs/python2/combinator.js +0 -1770
- package/src/langs/python2/config.js +0 -162
- package/src/langs/python2/files/.gitignore.tmpl +0 -5
- package/src/langs/python2/files/__init__.py.tmpl +0 -1
- package/src/langs/python2/files/setup.py.tmpl +0 -82
- package/src/langs/python2/package_info.js +0 -78
- package/src/lib/debug.js +0 -55
- package/src/lib/emitter.js +0 -95
- package/src/lib/helper.js +0 -207
- package/src/resolver/base.js +0 -282
- package/src/resolver/client.js +0 -1013
- package/src/resolver/model.js +0 -159
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const defaultConfig = require('../common/config');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
...defaultConfig,
|
|
7
|
-
indent: ' ',
|
|
8
|
-
ext: '.py',
|
|
9
|
-
keywords: {
|
|
10
|
-
general: [
|
|
11
|
-
'async',
|
|
12
|
-
'await',
|
|
13
|
-
'and',
|
|
14
|
-
'as',
|
|
15
|
-
'assert',
|
|
16
|
-
'break',
|
|
17
|
-
'class',
|
|
18
|
-
'continue',
|
|
19
|
-
'def',
|
|
20
|
-
'del',
|
|
21
|
-
'elif',
|
|
22
|
-
'else',
|
|
23
|
-
'except',
|
|
24
|
-
'finally',
|
|
25
|
-
'for',
|
|
26
|
-
'from',
|
|
27
|
-
'False',
|
|
28
|
-
'global',
|
|
29
|
-
'if',
|
|
30
|
-
'import',
|
|
31
|
-
'in',
|
|
32
|
-
'is',
|
|
33
|
-
'lambda',
|
|
34
|
-
'nonlocal',
|
|
35
|
-
'not',
|
|
36
|
-
'None',
|
|
37
|
-
'or',
|
|
38
|
-
'pass',
|
|
39
|
-
'raise',
|
|
40
|
-
'return',
|
|
41
|
-
'try',
|
|
42
|
-
'True',
|
|
43
|
-
'while',
|
|
44
|
-
'with',
|
|
45
|
-
'yield'
|
|
46
|
-
],
|
|
47
|
-
function: [],
|
|
48
|
-
class: [],
|
|
49
|
-
param_variables: [
|
|
50
|
-
'self'
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
symbolMap: {
|
|
54
|
-
'ASSIGN': '=',
|
|
55
|
-
'EQ': '==',
|
|
56
|
-
'NOT': 'NOT',
|
|
57
|
-
'AND': 'and',
|
|
58
|
-
'OR': 'or',
|
|
59
|
-
'PLUS': '+',
|
|
60
|
-
'SUB': '-',
|
|
61
|
-
'MULTI': '*',
|
|
62
|
-
'DIV': '/',
|
|
63
|
-
'POWER': '^',
|
|
64
|
-
'GREATER': '>',
|
|
65
|
-
'GREATER_EQ': '>=',
|
|
66
|
-
'LESS': '<',
|
|
67
|
-
'LESS_EQ': '<=',
|
|
68
|
-
'REVERSE': 'not ',
|
|
69
|
-
'CONCAT': '+'
|
|
70
|
-
},
|
|
71
|
-
typeHints: {
|
|
72
|
-
'READABLE': 'BinaryIO',
|
|
73
|
-
'WRITABLE': 'BinaryIO',
|
|
74
|
-
'any': 'Any',
|
|
75
|
-
'dict': 'Dict',
|
|
76
|
-
'list': 'List'
|
|
77
|
-
},
|
|
78
|
-
typeMap: {
|
|
79
|
-
'string': 'str',
|
|
80
|
-
'boolean': 'bool',
|
|
81
|
-
'number': 'int',
|
|
82
|
-
'integer': 'int',
|
|
83
|
-
'object': 'dict',
|
|
84
|
-
'map': 'dict',
|
|
85
|
-
'bytes': 'bytes',
|
|
86
|
-
'long': 'int',
|
|
87
|
-
'array': 'list',
|
|
88
|
-
'readable': 'READABLE',
|
|
89
|
-
'writable': 'WRITABLE',
|
|
90
|
-
'float': 'float',
|
|
91
|
-
'double': 'float',
|
|
92
|
-
'int64': 'int',
|
|
93
|
-
'int32': 'int',
|
|
94
|
-
'int16': 'int',
|
|
95
|
-
'int8': 'int',
|
|
96
|
-
'ulong': 'int',
|
|
97
|
-
'uint8': 'int',
|
|
98
|
-
'uint16': 'int',
|
|
99
|
-
'uint32': 'int',
|
|
100
|
-
'uint64': 'int',
|
|
101
|
-
'any': 'any',
|
|
102
|
-
'void': 'None',
|
|
103
|
-
'null': 'None'
|
|
104
|
-
},
|
|
105
|
-
type: {
|
|
106
|
-
// 'long': 'base',
|
|
107
|
-
// 'unicode': 'base',
|
|
108
|
-
// 'tuple': 'complex',
|
|
109
|
-
// 'set': 'complex',
|
|
110
|
-
'str': 'base',
|
|
111
|
-
'bytes': 'base',
|
|
112
|
-
'int': 'base',
|
|
113
|
-
'float': 'base',
|
|
114
|
-
'bool': 'base',
|
|
115
|
-
'None': 'base',
|
|
116
|
-
'dict': 'complex',
|
|
117
|
-
'list': 'complex',
|
|
118
|
-
'READABLE': 'custom',
|
|
119
|
-
'WRITABLE': 'custom'
|
|
120
|
-
},
|
|
121
|
-
exceptionMap: {
|
|
122
|
-
'BASE': 'Exception',
|
|
123
|
-
},
|
|
124
|
-
model: {
|
|
125
|
-
dir: 'models',
|
|
126
|
-
mode: 'single_file',
|
|
127
|
-
include: [],
|
|
128
|
-
},
|
|
129
|
-
client: {
|
|
130
|
-
defaultName: 'client',
|
|
131
|
-
include: []
|
|
132
|
-
},
|
|
133
|
-
tea: {
|
|
134
|
-
core: {
|
|
135
|
-
name: 'Tea.core.TeaCore',
|
|
136
|
-
doAction: 'do_action',
|
|
137
|
-
asyncDoAction: 'async_do_action',
|
|
138
|
-
allowRetry: 'allow_retry',
|
|
139
|
-
sleep: 'sleep',
|
|
140
|
-
getBackoffTime: 'get_backoff_time',
|
|
141
|
-
isRetryable: 'is_retryable',
|
|
142
|
-
toModel: 'toModel',
|
|
143
|
-
merge: 'merge',
|
|
144
|
-
toMap: 'to_map',
|
|
145
|
-
fromMap: 'from_map'
|
|
146
|
-
},
|
|
147
|
-
model: {
|
|
148
|
-
name: 'Tea.model.TeaModel'
|
|
149
|
-
},
|
|
150
|
-
converter: {
|
|
151
|
-
name: 'Converter'
|
|
152
|
-
},
|
|
153
|
-
response: {
|
|
154
|
-
name: 'Tea.response.TeaResponse'
|
|
155
|
-
},
|
|
156
|
-
request: {
|
|
157
|
-
name: 'Tea.request.TeaRequest'
|
|
158
|
-
},
|
|
159
|
-
exception: {
|
|
160
|
-
name: 'Tea.exceptions.TeaException'
|
|
161
|
-
},
|
|
162
|
-
error: {
|
|
163
|
-
name: 'Tea.exceptions.TeaException'
|
|
164
|
-
},
|
|
165
|
-
exceptionUnretryable: {
|
|
166
|
-
name: 'Tea.exceptions.UnretryableException'
|
|
167
|
-
},
|
|
168
|
-
}
|
|
169
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.0.1'
|
|
@@ -1,74 +0,0 @@
|
|
|
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 ${name}.
|
|
26
|
-
|
|
27
|
-
Created on ${date}
|
|
28
|
-
|
|
29
|
-
@author: ${author}
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
PACKAGE = "${package}"
|
|
33
|
-
NAME = "${name}" or "alibabacloud-package"
|
|
34
|
-
DESCRIPTION = "${desc}"
|
|
35
|
-
AUTHOR = "${author}"
|
|
36
|
-
AUTHOR_EMAIL = "${email}"
|
|
37
|
-
URL = "${github}"
|
|
38
|
-
VERSION = __import__(PACKAGE).__version__
|
|
39
|
-
REQUIRES = ${require}
|
|
40
|
-
|
|
41
|
-
LONG_DESCRIPTION = ''
|
|
42
|
-
if os.path.exists('./README.md'):
|
|
43
|
-
with open("README.md", encoding='utf-8') as fp:
|
|
44
|
-
LONG_DESCRIPTION = fp.read()
|
|
45
|
-
|
|
46
|
-
setup(
|
|
47
|
-
name=NAME,
|
|
48
|
-
version=VERSION,
|
|
49
|
-
description=DESCRIPTION,
|
|
50
|
-
long_description=LONG_DESCRIPTION,
|
|
51
|
-
long_description_content_type='text/markdown',
|
|
52
|
-
author=AUTHOR,
|
|
53
|
-
author_email=AUTHOR_EMAIL,
|
|
54
|
-
license="Apache License 2.0",
|
|
55
|
-
url=URL,
|
|
56
|
-
keywords=${keywords},
|
|
57
|
-
packages=find_packages(exclude=["tests*"]),
|
|
58
|
-
include_package_data=True,
|
|
59
|
-
platforms="any",
|
|
60
|
-
install_requires=REQUIRES,
|
|
61
|
-
python_requires=">=3.6",
|
|
62
|
-
classifiers=(
|
|
63
|
-
"Development Status :: 4 - Beta",
|
|
64
|
-
"Intended Audience :: Developers",
|
|
65
|
-
"License :: OSI Approved :: Apache Software License",
|
|
66
|
-
"Programming Language :: Python",
|
|
67
|
-
"Programming Language :: Python :: 3",
|
|
68
|
-
"Programming Language :: Python :: 3.6",
|
|
69
|
-
'Programming Language :: Python :: 3.7',
|
|
70
|
-
'Programming Language :: Python :: 3.8',
|
|
71
|
-
'Programming Language :: Python :: 3.9',
|
|
72
|
-
"Topic :: Software Development"
|
|
73
|
-
)
|
|
74
|
-
)
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const debug = require('../../lib/debug');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const BasePackageInfo = require('../common/package_info');
|
|
7
|
-
|
|
8
|
-
const OPTION_LOCAL = 1;
|
|
9
|
-
const OPTION_SOURCE = 2;
|
|
10
|
-
const OPTION_RENDER = 4;
|
|
11
|
-
|
|
12
|
-
// file_name : OPTIONS
|
|
13
|
-
const files = {
|
|
14
|
-
'.gitignore': OPTION_LOCAL,
|
|
15
|
-
'setup.py': OPTION_LOCAL | OPTION_RENDER | OPTION_SOURCE,
|
|
16
|
-
'LICENSE': OPTION_SOURCE,
|
|
17
|
-
'README-CN.md': OPTION_SOURCE | OPTION_RENDER,
|
|
18
|
-
'README.md': OPTION_SOURCE | OPTION_RENDER
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
class PackageInfo extends BasePackageInfo {
|
|
22
|
-
emit(packageInfo, requirePackage) {
|
|
23
|
-
let outputDir = path.join(this.config.dir, '../');
|
|
24
|
-
if (packageInfo.outputDir) {
|
|
25
|
-
outputDir = path.join(outputDir, packageInfo.outputDir);
|
|
26
|
-
}
|
|
27
|
-
if (!fs.existsSync(outputDir)) {
|
|
28
|
-
fs.mkdirSync(outputDir, {
|
|
29
|
-
recursive: true
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const checkParams = ['name', 'desc', 'github'];
|
|
33
|
-
checkParams.forEach(key => {
|
|
34
|
-
if (typeof packageInfo[key] === 'undefined') {
|
|
35
|
-
debug.stack('need config packageInfo.' + key, packageInfo);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
let requires = [];
|
|
40
|
-
requirePackage.forEach(packageItem => {
|
|
41
|
-
let packages = packageItem.split(':');
|
|
42
|
-
let version = packages[1];
|
|
43
|
-
const requireItem = `${packages[0]}>=${version}, <${parseInt(version.split('.')[0])+1}.0.0`;
|
|
44
|
-
requires.push(requireItem);
|
|
45
|
-
});
|
|
46
|
-
const date = new Date();
|
|
47
|
-
const keywords = JSON.stringify(packageInfo.name.split(/_|-/));
|
|
48
|
-
const params = {
|
|
49
|
-
email: '',
|
|
50
|
-
author: '',
|
|
51
|
-
package: this.config.package,
|
|
52
|
-
require: JSON.stringify(requires, null, 4),
|
|
53
|
-
namespace: this.config.package.split('.').join('\\\\'),
|
|
54
|
-
date: ('0' + date.getDate()).slice(-2) + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + '/' + date.getFullYear(),
|
|
55
|
-
keywords: keywords,
|
|
56
|
-
...packageInfo
|
|
57
|
-
};
|
|
58
|
-
Object.keys(files).forEach(filename => {
|
|
59
|
-
let content = '';
|
|
60
|
-
let optional = files[filename];
|
|
61
|
-
if (optional & OPTION_SOURCE && packageInfo.files && packageInfo.files[filename]) {
|
|
62
|
-
let filepath = path.isAbsolute(packageInfo.files[filename]) ?
|
|
63
|
-
packageInfo.files[filename] : path.join(this.config.pkgDir, packageInfo.files[filename]);
|
|
64
|
-
content = fs.readFileSync(filepath).toString();
|
|
65
|
-
} else if (optional & OPTION_LOCAL) {
|
|
66
|
-
content = fs.readFileSync(path.join(__dirname, './files/' + filename + '.tmpl')).toString();
|
|
67
|
-
}
|
|
68
|
-
if (content !== '') {
|
|
69
|
-
if (optional & OPTION_RENDER) {
|
|
70
|
-
content = this.render(content, params);
|
|
71
|
-
}
|
|
72
|
-
fs.writeFileSync(path.join(outputDir, filename), content);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = PackageInfo;
|