@darabonba/python-generator 1.2.19 → 2.0.1
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 +0 -158
- package/lib/builtin.js +818 -0
- package/lib/generator.js +2708 -0
- package/lib/helper.js +422 -0
- package/package.json +6 -5
- package/tests/expected/alias/setup.py +79 -0
- package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
- package/tests/expected/alias/tea_python_tests/client.py +35 -0
- package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
- package/tests/expected/annotation/tea_python_tests/client.py +93 -0
- package/tests/expected/annotation/tea_python_tests/models.py +37 -0
- package/tests/expected/api/tea_python_tests/__init__.py +1 -0
- package/tests/expected/api/tea_python_tests/client.py +106 -0
- package/tests/expected/builtin/tea_python_tests/client.py +685 -0
- package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
- package/tests/expected/comment/tea_python_tests/client.py +288 -0
- package/tests/expected/comment/tea_python_tests/models.py +195 -0
- package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
- package/tests/expected/complex/tea_python_tests/client.py +1169 -0
- package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/expected/complex/tea_python_tests/models.py +570 -0
- package/tests/expected/const/tea_python_tests/__init__.py +1 -0
- package/tests/expected/const/tea_python_tests/client.py +14 -0
- package/{src/langs/python/files/setup.py.tmpl → tests/expected/empty/setup.py} +11 -11
- package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
- package/tests/expected/empty/tea_python_tests/client.py +10 -0
- package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
- package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/expected/function/tea_python_tests/__init__.py +1 -0
- package/tests/expected/function/tea_python_tests/client.py +64 -0
- package/tests/expected/import/setup.py +78 -0
- package/tests/expected/import/tea_python_tests/__init__.py +1 -0
- package/tests/expected/import/tea_python_tests/client.py +29 -0
- package/tests/expected/map/tea_python_tests/__init__.py +1 -0
- package/tests/expected/map/tea_python_tests/client.py +39 -0
- package/tests/expected/model/tea_python_tests/__init__.py +1 -0
- package/tests/expected/model/tea_python_tests/client.py +10 -0
- package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
- package/tests/expected/model/tea_python_tests/models.py +780 -0
- package/tests/expected/multi/tea_python_tests/api.py +95 -0
- package/tests/expected/multi/tea_python_tests/client.py +40 -0
- package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/expected/multi/tea_python_tests/model/user.py +26 -0
- package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
- package/tests/expected/statements/tea_python_tests/client.py +86 -0
- package/tests/expected/super/tea_python_tests/__init__.py +1 -0
- package/tests/expected/super/tea_python_tests/client.py +16 -0
- package/tests/expected/typedef/setup.py +77 -0
- package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/typedef/tea_python_tests/client.py +74 -0
- package/tests/expected/typedef/tea_python_tests/models.py +42 -0
- package/tests/fixtures/alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
- package/tests/fixtures/builtin/Darafile +6 -0
- package/tests/fixtures/builtin/main.dara +333 -0
- package/tests/fixtures/complex/libraries/import.dara +18 -11
- package/tests/fixtures/complex/main.dara +452 -103
- package/tests/fixtures/import/libraries/Darafile +1 -1
- package/tests/fixtures/import/pack/Darafile +3 -0
- package/tests/fixtures/map/libraries/Darafile +3 -0
- package/tests/fixtures/map/libraries/import.dara +4 -0
- package/tests/fixtures/map/main.dara +17 -2
- package/tests/fixtures/model/.libraries.json +3 -0
- package/tests/fixtures/model/Darafile +5 -2
- package/tests/fixtures/model/libraries/Darafile +20 -0
- package/tests/fixtures/model/libraries/import.dara +27 -0
- package/tests/fixtures/model/main.dara +60 -42
- package/tests/fixtures/multi/.libraries.json +3 -0
- package/tests/fixtures/multi/Darafile +12 -0
- package/tests/fixtures/multi/api.dara +20 -0
- package/tests/fixtures/multi/lib/util.dara +5 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +68 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
- package/tests/fixtures/multi/main.dara +32 -0
- package/tests/fixtures/multi/model/user.dara +35 -0
- package/tests/{python3.tests.js → main.tests.js} +107 -65
- package/tests/output/alias/setup.py +79 -0
- package/tests/output/alias/tea_python_tests/client.py +35 -0
- package/{src/langs/python2/files/setup.py.tmpl → tests/output/annotation/setup.py} +19 -24
- package/tests/output/annotation/tea_python_tests/client.py +93 -0
- package/tests/output/annotation/tea_python_tests/models.py +37 -0
- package/tests/output/api/setup.py +77 -0
- package/tests/output/api/tea_python_tests/client.py +106 -0
- package/tests/output/builtin/setup.py +77 -0
- package/tests/output/builtin/tea_python_tests/client.py +685 -0
- package/tests/output/comment/setup.py +77 -0
- package/tests/output/comment/tea_python_tests/client.py +288 -0
- package/tests/output/comment/tea_python_tests/models.py +195 -0
- package/tests/output/complex/setup.py +77 -0
- package/tests/output/complex/tea_python_tests/client.py +1169 -0
- package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/output/complex/tea_python_tests/models.py +570 -0
- package/tests/output/const/setup.py +77 -0
- package/tests/output/const/tea_python_tests/client.py +14 -0
- package/tests/output/empty/setup.py +77 -0
- package/tests/output/empty/tea_python_tests/client.py +10 -0
- package/tests/output/exec/setup.py +77 -0
- package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/output/function/setup.py +77 -0
- package/tests/output/function/tea_python_tests/client.py +64 -0
- package/tests/output/import/setup.py +78 -0
- package/tests/output/import/tea_python_tests/client.py +29 -0
- package/tests/output/map/setup.py +77 -0
- package/tests/output/map/tea_python_tests/client.py +39 -0
- package/tests/output/model/setup.py +77 -0
- package/tests/output/model/tea_python_tests/client.py +10 -0
- package/tests/output/model/tea_python_tests/exceptions.py +28 -0
- package/tests/output/model/tea_python_tests/models.py +780 -0
- package/tests/output/multi/setup.py +77 -0
- package/tests/output/multi/tea_python_tests/api.py +95 -0
- package/tests/output/multi/tea_python_tests/client.py +40 -0
- package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/output/multi/tea_python_tests/model/user.py +26 -0
- package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/output/statements/setup.py +77 -0
- package/tests/output/statements/tea_python_tests/client.py +86 -0
- package/tests/output/super/setup.py +77 -0
- package/tests/output/super/tea_python_tests/client.py +16 -0
- package/tests/output/typedef/setup.py +78 -0
- package/tests/output/typedef/tea_python_tests/client.py +74 -0
- package/tests/output/typedef/tea_python_tests/models.py +42 -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/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/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
- package/tests/common.tests.js +0 -244
- package/tests/lib.tests.js +0 -269
- package/tests/python2.tests.js +0 -283
- package/tests/resolver.tests.js +0 -434
|
@@ -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,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;
|