@darabonba/python-generator 1.2.16 → 1.2.17

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.
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -16,8 +16,7 @@ jobs:
16
16
 
17
17
  strategy:
18
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/
19
+ node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
21
20
 
22
21
  steps:
23
22
  - uses: actions/checkout@v2
@@ -27,4 +26,5 @@ jobs:
27
26
  node-version: ${{ matrix.node-version }}
28
27
  - run: npm install
29
28
  - run: npm run ci
30
- - run: npm run test
29
+ - name: Upload coverage to Codecov
30
+ uses: codecov/codecov-action@v3
package/ChangeLog.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 1.2.17 - 2023-12-27
4
+ * Fix: correct model name when first letter is capitalized && and some keywords
5
+
3
6
  ## 1.2.16 - 2023-09-13
4
7
  * Feat: support importing additional package
5
8
 
package/README-CN.md CHANGED
@@ -2,17 +2,15 @@
2
2
 
3
3
  # Darabonba Python 生成器
4
4
 
5
- [![NPM version][npm-image]][npm-url]
5
+ [![CI](https://github.com/aliyun/darabonba-python-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/darabonba-python-generator/actions/workflows/ci.yml)
6
6
  [![codecov][cov-image]][cov-url]
7
- [![David deps][david-image]][david-url]
7
+ [![NPM version][npm-image]][npm-url]
8
8
  [![npm download][download-image]][download-url]
9
9
 
10
10
  [npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
11
11
  [npm-url]: https://npmjs.org/package/@darabonba/python-generator
12
12
  [cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
13
13
  [cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
14
- [david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
15
- [david-url]: https://david-dm.org/aliyun/darabonba-python-generator
16
14
  [download-image]: https://img.shields.io/npm/dm/@darabonba/python-generator.svg?style=flat-square
17
15
  [download-url]: https://npmjs.org/package/@darabonba/python-generator
18
16
 
package/README.md CHANGED
@@ -2,17 +2,15 @@ English | [简体中文](/README-CN.md)
2
2
 
3
3
  # Darabonba Python Generator
4
4
 
5
- [![NPM version][npm-image]][npm-url]
5
+ [![CI](https://github.com/aliyun/darabonba-python-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/darabonba-python-generator/actions/workflows/ci.yml)
6
6
  [![codecov][cov-image]][cov-url]
7
- [![David deps][david-image]][david-url]
7
+ [![NPM version][npm-image]][npm-url]
8
8
  [![npm download][download-image]][download-url]
9
9
 
10
10
  [npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
11
11
  [npm-url]: https://npmjs.org/package/@darabonba/python-generator
12
12
  [cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
13
13
  [cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
14
- [david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
15
- [david-url]: https://david-dm.org/aliyun/darabonba-python-generator
16
14
  [download-image]: https://img.shields.io/npm/dm/@darabonba/python-generator.svg?style=flat-square
17
15
  [download-url]: https://npmjs.org/package/@darabonba/python-generator
18
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darabonba/python-generator",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
4
4
  "description": "The darabonba generator for Python",
5
5
  "main": "src/generator.js",
6
6
  "directories": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "scripts": {
10
10
  "lint": "eslint --fix src/",
11
- "test": "mocha --reporter spec --timeout 3000 tests/*.tests.js",
12
- "test-cov": "nyc -r=lcov -r=html -r=text -r=json mocha -t 3000 -R spec tests/*.tests.js",
13
- "ci": "npm run lint && npm run test-cov && codecov"
11
+ "test": "mocha -R spec -t 3000 tests/*.tests.js",
12
+ "test-cov": "nyc -r=lcov -r=html -r=text -r=json npm run test",
13
+ "ci": "npm run lint && npm run test-cov"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -18,12 +18,11 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "chai": "^4.2.0",
21
- "codecov": "^3.8.1",
22
- "eslint": "^7.14.0",
21
+ "eslint": "^8.55.0",
23
22
  "expect.js": "^0.3.1",
24
- "has-flag": "^4.0.0",
23
+ "has-flag": "^5.0.1",
25
24
  "mm": "^3.2.0",
26
- "mocha": "^8.2.1",
25
+ "mocha": "^10.2.0",
27
26
  "mocha-sinon": "^2.1.2",
28
27
  "nyc": "^15.1.0",
29
28
  "sinon": "^9.2.1"
@@ -4,7 +4,12 @@ module.exports = {
4
4
  indent: ' ',
5
5
  ext: '.tea',
6
6
  resolvePathByPackage: false,
7
- keywords: [],
7
+ keywords: {
8
+ general: [],
9
+ function: [],
10
+ class: [],
11
+ param_variables: []
12
+ },
8
13
  typeMap: {},
9
14
  symbolMap: {},
10
15
  modifyOrder: [],
@@ -31,7 +31,9 @@ const {
31
31
  _toSnakeCase,
32
32
  _toCamelCase,
33
33
  _avoidKeywords,
34
- _isKeywords,
34
+ _avoidFuncKeywords,
35
+ _avoidClassKeywords,
36
+ _avoidVarKeywords,
35
37
  _exception,
36
38
  _symbol,
37
39
  _deepClone,
@@ -46,6 +48,14 @@ function _name(name) {
46
48
  return _avoidKeywords(_toSnakeCase(name));
47
49
  }
48
50
 
51
+ function _varName(name){
52
+ return _avoidVarKeywords(_toSnakeCase(name));
53
+ }
54
+
55
+ function _funcName(name){
56
+ return _avoidFuncKeywords(_toSnakeCase(name));
57
+ }
58
+
49
59
  function _type(type) {
50
60
  const config = _config();
51
61
  let t = type instanceof Object ? type.lexeme : type;
@@ -446,10 +456,7 @@ class Combinator extends CombinatorBase {
446
456
  } else {
447
457
  className = name.split('.').map(item => _upperFirst(item)).join('');
448
458
  }
449
- if (_isKeywords(className)) {
450
- className = _avoidKeywords(className);
451
- }
452
- return _toCamelCase(className);
459
+ return _toCamelCase(_avoidClassKeywords(className));
453
460
  }
454
461
 
455
462
  emitClass(emitter, object) {
@@ -502,7 +509,7 @@ class Combinator extends CombinatorBase {
502
509
  } else if (p instanceof PropItem) {
503
510
  const type = this.getTypeHints(p.type);
504
511
  if (type) {
505
- emitter.emitln(`${_name(p.name)}: ${type} = None`, this.level);
512
+ emitter.emitln(`${_varName(p.name)}: ${type} = None`, this.level);
506
513
  }
507
514
  }
508
515
  });
@@ -670,7 +677,7 @@ class Combinator extends CombinatorBase {
670
677
  type: type.itemType,
671
678
  parentType: type.lexeme
672
679
  };
673
- this.emitComplexToMap(emitter, propInfo, `result['${name}']`, depth + 1);
680
+ this.emitComplexToMap(emitter, propInfo, `result['${fieldName}']`, depth + 1);
674
681
  } else {
675
682
  if (type.itemType.objectType === 'model') {
676
683
  emitter.emitln(`result['${fieldName}'].append(k.to_map() if k else None)`, this.level);
@@ -714,7 +721,7 @@ class Combinator extends CombinatorBase {
714
721
  type: type.valType,
715
722
  parentType: type.lexeme
716
723
  };
717
- this.emitComplexToMap(emitter, propInfo, `result['${name}']`, depth + 1);
724
+ this.emitComplexToMap(emitter, propInfo, `result['${fieldName}']`, depth + 1);
718
725
  } else {
719
726
  if (type.valType.objectType === 'model') {
720
727
  emitter.emitln(`result['${fieldName}'][k] = v.to_map()`, this.level);
@@ -956,9 +963,9 @@ class Combinator extends CombinatorBase {
956
963
  construct.params.forEach(param => {
957
964
  const typeHints = this.getTypeHints(param.type);
958
965
  if (param.value !== null && param.value !== 'null') {
959
- constructParams.push(`${_name(param.key)}: ${typeHints} = ${param.value},`);
966
+ constructParams.push(`${_varName(param.key)}: ${typeHints} = ${param.value},`);
960
967
  } else {
961
- constructParams.push(`${_name(param.key)}: ${typeHints},`);
968
+ constructParams.push(`${_varName(param.key)}: ${typeHints},`);
962
969
  }
963
970
  });
964
971
  emitter.emitln('def __init__(', this.level);
@@ -978,9 +985,9 @@ class Combinator extends CombinatorBase {
978
985
  if (prop instanceof PropItem) {
979
986
  const typeHints = this.getTypeHints(prop.type);
980
987
  if (typeHints === this.className) {
981
- emitter.emitln(`${_name(prop.name)}: '${typeHints}' = None,`, this.level);
988
+ emitter.emitln(`${_varName(prop.name)}: '${typeHints}' = None,`, this.level);
982
989
  } else {
983
- emitter.emitln(`${_name(prop.name)}: ${typeHints} = None,`, this.level);
990
+ emitter.emitln(`${_varName(prop.name)}: ${typeHints} = None,`, this.level);
984
991
  }
985
992
 
986
993
  }
@@ -1016,7 +1023,7 @@ class Combinator extends CombinatorBase {
1016
1023
  emitter.emitln(`# ${d}`, this.level);
1017
1024
  });
1018
1025
  }
1019
- emitter.emitln(`self.${_name(prop.name)} = ${_name(prop.name)}`, this.level);
1026
+ emitter.emitln(`self.${_name(prop.name)} = ${_varName(prop.name)}`, this.level);
1020
1027
  });
1021
1028
  if (construct.body.length > 0) {
1022
1029
  construct.body.forEach(gram => {
@@ -1115,19 +1122,19 @@ class Combinator extends CombinatorBase {
1115
1122
  let selfVar = this.func_static ? '' : 'self';
1116
1123
 
1117
1124
  if (func.params.length > 0) {
1118
- emitter.emitln(`def ${_name(func.name)}_async(`);
1125
+ emitter.emitln(`def ${_funcName(func.name)}_async(`);
1119
1126
  this.levelUp();
1120
1127
  if (selfVar) {
1121
1128
  emitter.emitln(`${selfVar},`, this.level);
1122
1129
  }
1123
1130
  func.params.forEach(p => {
1124
1131
  const type = this.getTypeHints(p.type);
1125
- emitter.emitln(`${_name(p.key)}: ${type},`, this.level);
1132
+ emitter.emitln(`${_varName(p.key)}: ${type},`, this.level);
1126
1133
  });
1127
1134
  this.levelDown();
1128
1135
  emitter.emitln(`) -> ${rtype}:`, this.level);
1129
1136
  } else {
1130
- emitter.emit(`def ${_name(func.name)}_async(`);
1137
+ emitter.emit(`def ${_funcName(func.name)}_async(`);
1131
1138
  if (selfVar) {
1132
1139
  emitter.emit(`${selfVar}`);
1133
1140
  }
@@ -1158,19 +1165,19 @@ class Combinator extends CombinatorBase {
1158
1165
  let selfVar = this.func_static ? '' : 'self';
1159
1166
 
1160
1167
  if (func.params.length > 0) {
1161
- emitter.emitln(`def ${_name(func.name)}(`);
1168
+ emitter.emitln(`def ${_funcName(func.name)}(`);
1162
1169
  this.levelUp();
1163
1170
  if (selfVar) {
1164
1171
  emitter.emitln(`${selfVar},`, this.level);
1165
1172
  }
1166
1173
  func.params.forEach(p => {
1167
1174
  const type = this.getTypeHints(p.type);
1168
- emitter.emitln(`${_name(p.key)}: ${type},`, this.level);
1175
+ emitter.emitln(`${_varName(p.key)}: ${type},`, this.level);
1169
1176
  });
1170
1177
  this.levelDown();
1171
1178
  emitter.emitln(`) -> ${rtype}:`, this.level);
1172
1179
  } else {
1173
- emitter.emit(`def ${_name(func.name)}(`);
1180
+ emitter.emit(`def ${_funcName(func.name)}(`);
1174
1181
  if (selfVar) {
1175
1182
  emitter.emit(`${selfVar}`);
1176
1183
  }
@@ -1349,12 +1356,12 @@ class Combinator extends CombinatorBase {
1349
1356
  pre += `.${_name(path.name)}`;
1350
1357
  }
1351
1358
  } else if (path.type === 'object') {
1352
- pre += `${_name(_convertStaticParam(pathName))}`;
1359
+ pre += `${_varName(_convertStaticParam(pathName))}`;
1353
1360
  } else if (path.type === 'object_async') {
1354
1361
  if (this.aioMode) {
1355
- pre += `await ${_name(_convertStaticParam(pathName))}`;
1362
+ pre += `await ${_varName(_convertStaticParam(pathName))}`;
1356
1363
  } else {
1357
- pre += `${_name(_convertStaticParam(pathName))}`;
1364
+ pre += `${_varName(_convertStaticParam(pathName))}`;
1358
1365
  }
1359
1366
  } else if (path.type === 'object_static') {
1360
1367
  pre += `${_convertStaticParam(pathName)}`;
@@ -1365,24 +1372,24 @@ class Combinator extends CombinatorBase {
1365
1372
  pre += `${_convertStaticParam(pathName)}`;
1366
1373
  }
1367
1374
  } else if (path.type === 'call' || path.type === 'call_static') {
1368
- pre += `.${_name(pathName)}(${params})`;
1375
+ pre += `.${_funcName(pathName)}(${params})`;
1369
1376
  } else if (path.type === 'call_async' || path.type === 'call_static_async') {
1370
1377
  if (this.aioMode) {
1371
- pre += `.${_name(pathName)}_async(${params})`;
1378
+ pre += `.${_funcName(pathName)}_async(${params})`;
1372
1379
  } else {
1373
- pre += `.${_name(pathName)}(${params})`;
1380
+ pre += `.${_funcName(pathName)}(${params})`;
1374
1381
  }
1375
1382
  } else if (path.type === 'prop') {
1376
1383
  pre += `.${_name(pathName)}`;
1377
1384
  } else if (path.type === 'prop_static') {
1378
1385
  pre += `.${_name(pathName)}`;
1379
1386
  } else if (path.type === 'map') {
1380
- pre += path.isVar ? `.get(${_name(pathName)})` : `.get('${pathName}')`;
1387
+ pre += path.isVar ? `.get(${_varName(pathName)})` : `.get('${pathName}')`;
1381
1388
  } else if (path.type === 'map_set') {
1382
1389
  const quote = this._adaptedQuotes(pathName, emitter);
1383
1390
  pre += `[${quote}${pathName}${quote}]`;
1384
1391
  } else if (path.type === 'list') {
1385
- pre += path.isVar ? `[${_name(pathName)}]` : `[${pathName}]`;
1392
+ pre += path.isVar ? `[${_varName(pathName)}]` : `[${pathName}]`;
1386
1393
  } else {
1387
1394
  debug.stack(gram);
1388
1395
  }
@@ -1411,7 +1418,7 @@ class Combinator extends CombinatorBase {
1411
1418
  emitter.emit(`${name}()`);
1412
1419
  } else if (gram.varType === 'var' || gram.varType === 'const') {
1413
1420
  const name = gram.name ? gram.name : gram.key;
1414
- emitter.emit(`${_convertStaticParam(_name(name))}`);
1421
+ emitter.emit(`${_convertStaticParam(_varName(name))}`);
1415
1422
  } else {
1416
1423
  debug.stack(gram);
1417
1424
  }
@@ -1423,7 +1430,7 @@ class Combinator extends CombinatorBase {
1423
1430
  const quote = this._adaptedQuotes(gram.key, emitter);
1424
1431
  emitter.emit(`${quote}${gram.key}${quote}: `);
1425
1432
  } else {
1426
- emitter.emit(`${_name(gram.key)}=`, this.level);
1433
+ emitter.emit(`${_varName(gram.key)}=`, this.level);
1427
1434
  }
1428
1435
  }
1429
1436
  if (gram instanceof GrammerCall) {
@@ -1539,7 +1546,7 @@ class Combinator extends CombinatorBase {
1539
1546
  const quote = this._adaptedQuotes(gram.value, emitter);
1540
1547
  emitter.emit(`${quote}${gram.value}${quote}`);
1541
1548
  } else if (gram.type === 'param') {
1542
- emitter.emit(`${_convertStaticParam(_name(gram.value))}`);
1549
+ emitter.emit(`${_convertStaticParam(_varName(gram.value))}`);
1543
1550
  } else if (gram.type === 'call') {
1544
1551
  this.grammerCall(emitter, gram.value);
1545
1552
  } else if (gram.type === 'number') {
@@ -1759,7 +1766,7 @@ class Combinator extends CombinatorBase {
1759
1766
  gram.params.forEach(p => {
1760
1767
  let emit = new Emitter();
1761
1768
  if (p.key) {
1762
- emit.emit(`${_name(p.key)}`);
1769
+ emit.emit(`${_varName(p.key)}`);
1763
1770
  emit.emit('=');
1764
1771
  }
1765
1772
  if (typeof (p.value) === 'string') {
@@ -1789,7 +1796,7 @@ class Combinator extends CombinatorBase {
1789
1796
  this.grammerCall(emit, behavior.call);
1790
1797
 
1791
1798
  if (behavior.isVar) {
1792
- emitter.emit(`${emit.output}[${_name(behavior.key)}] = `, this.level);
1799
+ emitter.emit(`${emit.output}[${_varName(behavior.key)}] = `, this.level);
1793
1800
  } else {
1794
1801
  const quote = this._adaptedQuotes(behavior.key, emitter);
1795
1802
  emitter.emit(`${emit.output}[${quote}${behavior.key}${quote}] = `, this.level);
@@ -6,44 +6,50 @@ module.exports = {
6
6
  ...defaultConfig,
7
7
  indent: ' ',
8
8
  ext: '.py',
9
- keywords: [
10
- 'self',
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
- ],
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
+ },
47
53
  symbolMap: {
48
54
  'ASSIGN': '=',
49
55
  'EQ': '==',
@@ -31,7 +31,9 @@ const {
31
31
  _toSnakeCase,
32
32
  _toCamelCase,
33
33
  _avoidKeywords,
34
- _isKeywords,
34
+ _avoidFuncKeywords,
35
+ _avoidClassKeywords,
36
+ _avoidVarKeywords,
35
37
  _exception,
36
38
  _symbol,
37
39
  _deepClone,
@@ -43,6 +45,14 @@ function _name(name) {
43
45
  return _avoidKeywords(_toSnakeCase(name));
44
46
  }
45
47
 
48
+ function _varName(name){
49
+ return _avoidVarKeywords(_toSnakeCase(name));
50
+ }
51
+
52
+ function _funcName(name){
53
+ return _avoidFuncKeywords(_toSnakeCase(name));
54
+ }
55
+
46
56
  function _type(type) {
47
57
  const config = _config();
48
58
  let t = type instanceof Object ? type.lexeme : type;
@@ -387,10 +397,7 @@ class Combinator extends CombinatorBase {
387
397
  } else {
388
398
  className = name.split('.').map(item => _upperFirst(item)).join('');
389
399
  }
390
- if (_isKeywords(className)) {
391
- className = _avoidKeywords(className);
392
- }
393
- return _toCamelCase(className);
400
+ return _toCamelCase(_avoidClassKeywords(className));
394
401
  }
395
402
 
396
403
  emitClass(emitter, object) {
@@ -444,7 +451,7 @@ class Combinator extends CombinatorBase {
444
451
  } else if (p instanceof PropItem) {
445
452
  const type = this.typeHint(p.type);
446
453
  if (type) {
447
- emitter.emitln(`${_name(p.name)} = None # type: ${type}`, this.level);
454
+ emitter.emitln(`${_varName(p.name)} = None # type: ${type}`, this.level);
448
455
  }
449
456
  }
450
457
  });
@@ -611,7 +618,7 @@ class Combinator extends CombinatorBase {
611
618
  type: type.itemType,
612
619
  parentType: type.lexeme
613
620
  };
614
- this.emitComplexToMap(emitter, propInfo, `result['${name}']`, depth + 1);
621
+ this.emitComplexToMap(emitter, propInfo, `result['${fieldName}']`, depth + 1);
615
622
  } else {
616
623
  if (type.itemType.objectType === 'model') {
617
624
  emitter.emitln(`result['${fieldName}'].append(k.to_map() if k else None)`, this.level);
@@ -655,7 +662,7 @@ class Combinator extends CombinatorBase {
655
662
  type: type.valType,
656
663
  parentType: type.lexeme
657
664
  };
658
- this.emitComplexToMap(emitter, propInfo, `result['${name}']`, depth + 1);
665
+ this.emitComplexToMap(emitter, propInfo, `result['${fieldName}']`, depth + 1);
659
666
  } else {
660
667
  if (type.valType.objectType === 'model') {
661
668
  emitter.emitln(`result['${fieldName}'][k] = v.to_map()`, this.level);
@@ -896,9 +903,9 @@ class Combinator extends CombinatorBase {
896
903
  let constructParams = [];
897
904
  construct.params.forEach(param => {
898
905
  if (param.value !== null && param.value !== 'null') {
899
- constructParams.push(`${_name(param.key)}=${param.value}`);
906
+ constructParams.push(`${_varName(param.key)}=${param.value}`);
900
907
  } else {
901
- constructParams.push(`${_name(param.key)}`);
908
+ constructParams.push(`${_varName(param.key)}`);
902
909
  }
903
910
  });
904
911
  emitter.emit('def __init__(self', this.level);
@@ -914,7 +921,7 @@ class Combinator extends CombinatorBase {
914
921
  let curr_length = 0;
915
922
  props.forEach((prop) => {
916
923
  if (prop instanceof PropItem) {
917
- let str = ` ${_name(prop.name)}=None`;
924
+ let str = ` ${_varName(prop.name)}=None`;
918
925
  if(curr_length+str.length>=max_length){
919
926
  str = emitter.eol + emitter.indent(this.level + 3) + str;
920
927
  curr_length = 0;
@@ -958,7 +965,7 @@ class Combinator extends CombinatorBase {
958
965
  }
959
966
 
960
967
  const fieldType = this.typeHint(prop.type);
961
- emitter.emitln(`self.${_name(prop.name)} = ${_name(prop.name)} # type: ${fieldType}`, this.level);
968
+ emitter.emitln(`self.${_name(prop.name)} = ${_varName(prop.name)} # type: ${fieldType}`, this.level);
962
969
  });
963
970
  if (construct.body.length > 0) {
964
971
  construct.body.forEach(gram => {
@@ -1014,17 +1021,17 @@ class Combinator extends CombinatorBase {
1014
1021
  }
1015
1022
  if (func.params.length > 0) {
1016
1023
  let selfVar = this.func_static ? '' : 'self, ';
1017
- emitter.emit(`def ${_name(func.name)}(${selfVar}`, this.level);
1024
+ emitter.emit(`def ${_funcName(func.name)}(${selfVar}`, this.level);
1018
1025
  if (func.params.length > 0) {
1019
1026
  let params = [];
1020
1027
  func.params.forEach(p => {
1021
- params.push(`${_name(p.key)}`);
1028
+ params.push(`${_varName(p.key)}`);
1022
1029
  });
1023
1030
  emitter.emit(params.join(', '));
1024
1031
  }
1025
1032
  } else {
1026
1033
  let selfVar = this.func_static ? '' : 'self';
1027
- emitter.emit(`def ${_name(func.name)}(${selfVar}`, this.level);
1034
+ emitter.emit(`def ${_funcName(func.name)}(${selfVar}`, this.level);
1028
1035
  }
1029
1036
  emitter.emitln('):');
1030
1037
  this.levelUp();
@@ -1216,24 +1223,24 @@ class Combinator extends CombinatorBase {
1216
1223
  pre += `.${_name(path.name)}`;
1217
1224
  }
1218
1225
  } else if (path.type === 'object' || path.type === 'object_async') {
1219
- pre += `${_name(_convertStaticParam(pathName))}`;
1226
+ pre += `${_varName(_convertStaticParam(pathName))}`;
1220
1227
  } else if (path.type === 'object_static' || path.type === 'object_static_async') {
1221
1228
  pre += `${_convertStaticParam(pathName)}`;
1222
1229
  } else if (path.type === 'call' || path.type === 'call_static') {
1223
- pre += `.${_name(pathName)}(${params})`;
1230
+ pre += `.${_funcName(pathName)}(${params})`;
1224
1231
  } else if (path.type === 'call_async' || path.type === 'call_static_async') {
1225
- pre += `.${_name(pathName)}(${params})`;
1232
+ pre += `.${_funcName(pathName)}(${params})`;
1226
1233
  } else if (path.type === 'prop') {
1227
1234
  pre += `.${_name(pathName)}`;
1228
1235
  } else if (path.type === 'prop_static') {
1229
1236
  pre += `.${_name(pathName)}`;
1230
1237
  } else if (path.type === 'map') {
1231
- pre += path.isVar ? `.get(${_name(pathName)})` : `.get('${pathName}')`;
1238
+ pre += path.isVar ? `.get(${_varName(pathName)})` : `.get('${pathName}')`;
1232
1239
  } else if (path.type === 'map_set') {
1233
1240
  const quote = this._adaptedQuotes(pathName, emitter);
1234
1241
  pre += `[${quote}${pathName}${quote}]`;
1235
1242
  } else if (path.type === 'list') {
1236
- pre += path.isVar ? `[${_name(pathName)}]` : `[${pathName}]`;
1243
+ pre += path.isVar ? `[${_varName(pathName)}]` : `[${pathName}]`;
1237
1244
  } else {
1238
1245
  debug.stack(gram);
1239
1246
  }
@@ -1276,7 +1283,7 @@ class Combinator extends CombinatorBase {
1276
1283
  emitter.emit(`${name}()`);
1277
1284
  } else if (gram.varType === 'var' || gram.varType === 'const') {
1278
1285
  const name = gram.name ? gram.name : gram.key;
1279
- emitter.emit(`${_convertStaticParam(_name(name))}`);
1286
+ emitter.emit(`${_convertStaticParam(_varName(name))}`);
1280
1287
  } else {
1281
1288
  debug.stack(gram);
1282
1289
  }
@@ -1288,7 +1295,7 @@ class Combinator extends CombinatorBase {
1288
1295
  const quote = this._adaptedQuotes(gram.key, emitter);
1289
1296
  emitter.emit(`${quote}${gram.key}${quote}: `);
1290
1297
  } else {
1291
- emitter.emit(`${_name(gram.key)}=`, this.level);
1298
+ emitter.emit(`${_varName(gram.key)}=`, this.level);
1292
1299
  }
1293
1300
  }
1294
1301
  if (gram instanceof GrammerCall) {
@@ -1404,7 +1411,7 @@ class Combinator extends CombinatorBase {
1404
1411
  const quote = this._adaptedQuotes(gram.value, emitter);
1405
1412
  emitter.emit(`${quote}${gram.value}${quote}`);
1406
1413
  } else if (gram.type === 'param') {
1407
- emitter.emit(`${_convertStaticParam(_name(gram.value))}`);
1414
+ emitter.emit(`${_convertStaticParam(_varName(gram.value))}`);
1408
1415
  } else if (gram.type === 'call') {
1409
1416
  this.grammerCall(emitter, gram.value);
1410
1417
  } else if (gram.type === 'number') {
@@ -1618,7 +1625,7 @@ class Combinator extends CombinatorBase {
1618
1625
  gram.params.forEach(p => {
1619
1626
  let emit = new Emitter();
1620
1627
  if (p.key) {
1621
- emit.emit(`${_name(p.key)}`);
1628
+ emit.emit(`${_varName(p.key)}`);
1622
1629
  emit.emit('=');
1623
1630
  }
1624
1631
  if (typeof (p.value) === 'string') {
@@ -1648,7 +1655,7 @@ class Combinator extends CombinatorBase {
1648
1655
  this.grammerCall(emit, behavior.call);
1649
1656
 
1650
1657
  if (behavior.isVar) {
1651
- emitter.emit(`${emit.output}[${_name(behavior.key)}] = `, this.level);
1658
+ emitter.emit(`${emit.output}[${_varName(behavior.key)}] = `, this.level);
1652
1659
  } else {
1653
1660
  const quote = this._adaptedQuotes(behavior.key, emitter);
1654
1661
  emitter.emit(`${emit.output}[${quote}${behavior.key}${quote}] = `, this.level);
@@ -6,40 +6,49 @@ module.exports = {
6
6
  ...defaultConfig,
7
7
  indent: ' ',
8
8
  ext: '.py',
9
- keywords: [
10
- 'and',
11
- 'as',
12
- 'assert',
13
- 'break',
14
- 'class',
15
- 'continue',
16
- 'def',
17
- 'del',
18
- 'elif',
19
- 'else',
20
- 'except',
21
- 'finally',
22
- 'for',
23
- 'from',
24
- 'False',
25
- 'global',
26
- 'if',
27
- 'import',
28
- 'in',
29
- 'is',
30
- 'lambda',
31
- 'not',
32
- 'None',
33
- 'or',
34
- 'pass',
35
- 'raise',
36
- 'return',
37
- 'try',
38
- 'True',
39
- 'while',
40
- 'with',
41
- 'yield'
42
- ],
9
+ keywords: {
10
+ general: [
11
+ 'and',
12
+ 'as',
13
+ 'assert',
14
+ 'break',
15
+ 'class',
16
+ 'continue',
17
+ 'def',
18
+ 'del',
19
+ 'elif',
20
+ 'else',
21
+ 'except',
22
+ 'finally',
23
+ 'for',
24
+ 'from',
25
+ 'False',
26
+ 'global',
27
+ 'if',
28
+ 'import',
29
+ 'in',
30
+ 'is',
31
+ 'lambda',
32
+ 'not',
33
+ 'None',
34
+ 'or',
35
+ 'pass',
36
+ 'raise',
37
+ 'return',
38
+ 'try',
39
+ 'True',
40
+ 'while',
41
+ 'with',
42
+ 'yield'
43
+ ],
44
+ function: [],
45
+ class: [],
46
+ param_variables: [
47
+ 'exec',
48
+ 'print',
49
+ 'self'
50
+ ]
51
+ },
43
52
  symbolMap: {
44
53
  'ASSIGN': '=',
45
54
  'EQ': '==',
package/src/lib/helper.js CHANGED
@@ -53,7 +53,31 @@ function _deepClone(obj) {
53
53
  }
54
54
 
55
55
  function _avoidKeywords(str) {
56
- if (config.keywords.indexOf(str.toLowerCase()) > -1) {
56
+ if (config.keywords.general.indexOf(str.toLowerCase()) > -1) {
57
+ return str + '_';
58
+ }
59
+ return str;
60
+ }
61
+
62
+ function _avoidFuncKeywords(str) {
63
+ if (config.keywords.general.indexOf(str.toLowerCase()) > -1
64
+ || config.keywords.function.indexOf(str.toLowerCase()) > -1) {
65
+ return str + '_';
66
+ }
67
+ return str;
68
+ }
69
+
70
+ function _avoidClassKeywords(str) {
71
+ if (config.keywords.general.indexOf(str.toLowerCase()) > -1
72
+ || config.keywords.class.indexOf(str.toLowerCase()) > -1) {
73
+ return str + '_';
74
+ }
75
+ return str;
76
+ }
77
+
78
+ function _avoidVarKeywords(str) {
79
+ if (config.keywords.general.indexOf(str.toLowerCase()) > -1
80
+ || config.keywords.param_variables.indexOf(str.toLowerCase()) > -1) {
57
81
  return str + '_';
58
82
  }
59
83
  return str;
@@ -69,7 +93,7 @@ function _convertStaticParam(param) {
69
93
  }
70
94
 
71
95
  function _isKeywords(str) {
72
- return config.keywords.indexOf(str.toLowerCase()) > -1;
96
+ return config.keywords.general.indexOf(str.toLowerCase()) > -1;
73
97
  }
74
98
 
75
99
  function _modify(modify) {
@@ -159,6 +183,9 @@ module.exports = {
159
183
  _isBasicType,
160
184
  _deepClone,
161
185
  _avoidKeywords,
186
+ _avoidFuncKeywords,
187
+ _avoidClassKeywords,
188
+ _avoidVarKeywords,
162
189
  _convertStaticParam,
163
190
  _isKeywords,
164
191
  _modify,
@@ -118,9 +118,33 @@ class ComplexRequestComplexList(TeaModel):
118
118
  return self
119
119
 
120
120
 
121
+ class ComplexRequestComplexList2(TeaModel):
122
+ def __init__(self, any=None):
123
+ self.any = any # type: any
124
+
125
+ def validate(self):
126
+ pass
127
+
128
+ def to_map(self):
129
+ _map = super(ComplexRequestComplexList2, self).to_map()
130
+ if _map is not None:
131
+ return _map
132
+
133
+ result = dict()
134
+ if self.any is not None:
135
+ result['Name'] = self.any
136
+ return result
137
+
138
+ def from_map(self, m=None):
139
+ m = m or dict()
140
+ if m.get('Name') is not None:
141
+ self.any = m.get('Name')
142
+ return self
143
+
144
+
121
145
  class ComplexRequest(TeaModel):
122
146
  def __init__(self, access_key=None, body=None, strs=None, header=None, num=None, configs=None, part=None,
123
- complex_list=None, complex_list_1=None, from_=None):
147
+ complex_list=None, complex_list_1=None, complex_list_2=None, from_=None, self_=None, print_=None, exec_=None):
124
148
  self.access_key = access_key # type: str
125
149
  # Body
126
150
  self.body = body # type: READABLE
@@ -134,8 +158,15 @@ class ComplexRequest(TeaModel):
134
158
  self.part = part # type: list[ComplexRequestPart]
135
159
  self.complex_list = complex_list # type: list[list[list[ComplexRequestComplexList]]]
136
160
  self.complex_list_1 = complex_list_1 # type: list[list[dict[str, str]]]
161
+ self.complex_list_2 = complex_list_2 # type: list[list[list[ComplexRequestComplexList2]]]
137
162
  # test keywords
138
163
  self.from_ = from_ # type: str
164
+ # test keywords
165
+ self.self = self_ # type: str
166
+ # test keywords
167
+ self.print = print_ # type: str
168
+ # test keywords
169
+ self.exec = exec_ # type: str
139
170
 
140
171
  def validate(self):
141
172
  self.validate_required(self.access_key, 'access_key')
@@ -160,7 +191,17 @@ class ComplexRequest(TeaModel):
160
191
  if k2:
161
192
  k2.validate()
162
193
  self.validate_required(self.complex_list_1, 'complex_list_1')
194
+ self.validate_required(self.complex_list_2, 'complex_list_2')
195
+ if self.complex_list_2:
196
+ for k in self.complex_list_2:
197
+ for k1 in k:
198
+ for k2 in k1:
199
+ if k2:
200
+ k2.validate()
163
201
  self.validate_required(self.from_, 'from_')
202
+ self.validate_required(self.self, 'self')
203
+ self.validate_required(self.print, 'print')
204
+ self.validate_required(self.exec, 'exec')
164
205
 
165
206
  def to_map(self):
166
207
  _map = super(ComplexRequest, self).to_map()
@@ -196,8 +237,24 @@ class ComplexRequest(TeaModel):
196
237
  result['complexList'].append(l1)
197
238
  if self.complex_list_1 is not None:
198
239
  result['complexList1'] = self.complex_list_1
240
+ result['ComplexList2'] = []
241
+ if self.complex_list_2 is not None:
242
+ for k in self.complex_list_2:
243
+ l1 = []
244
+ for k1 in k:
245
+ l2 = []
246
+ for k2 in k1:
247
+ l2.append(k2.to_map() if k2 else None)
248
+ l1.append(l2)
249
+ result['ComplexList2'].append(l1)
199
250
  if self.from_ is not None:
200
251
  result['from'] = self.from_
252
+ if self.self is not None:
253
+ result['self'] = self.self
254
+ if self.print is not None:
255
+ result['print'] = self.print
256
+ if self.exec is not None:
257
+ result['exec'] = self.exec
201
258
  return result
202
259
 
203
260
  def from_map(self, m=None):
@@ -234,8 +291,25 @@ class ComplexRequest(TeaModel):
234
291
  self.complex_list.append(l1)
235
292
  if m.get('complexList1') is not None:
236
293
  self.complex_list_1 = m.get('complexList1')
294
+ self.complex_list_2 = []
295
+ if m.get('ComplexList2') is not None:
296
+ for k in m.get('ComplexList2'):
297
+ l1 = []
298
+ for k1 in k:
299
+ l2 = []
300
+ for k2 in k1:
301
+ temp_model = ComplexRequestComplexList2()
302
+ l2.append(temp_model.from_map(k2))
303
+ l1.append(l2)
304
+ self.complex_list_2.append(l1)
237
305
  if m.get('from') is not None:
238
306
  self.from_ = m.get('from')
307
+ if m.get('self') is not None:
308
+ self.self = m.get('self')
309
+ if m.get('print') is not None:
310
+ self.print = m.get('print')
311
+ if m.get('exec') is not None:
312
+ self.exec = m.get('exec')
239
313
  return self
240
314
 
241
315
 
@@ -25,7 +25,7 @@ from setuptools import setup, find_packages
25
25
  """
26
26
  setup module for tea_python_tests.
27
27
 
28
- Created on 13/09/2023
28
+ Created on *
29
29
 
30
30
  @author: Alibaba
31
31
  """
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from Tea.model import TeaModel
4
- from typing import List, Dict, BinaryIO
4
+ from typing import List, Dict, Any, BinaryIO
5
5
 
6
6
 
7
7
  class ComplexRequestHeader(TeaModel):
@@ -134,6 +134,33 @@ class ComplexRequestComplexList(TeaModel):
134
134
  return self
135
135
 
136
136
 
137
+ class ComplexRequestComplexList2(TeaModel):
138
+ def __init__(
139
+ self,
140
+ any: Any = None,
141
+ ):
142
+ self.any = any
143
+
144
+ def validate(self):
145
+ pass
146
+
147
+ def to_map(self):
148
+ _map = super().to_map()
149
+ if _map is not None:
150
+ return _map
151
+
152
+ result = dict()
153
+ if self.any is not None:
154
+ result['Name'] = self.any
155
+ return result
156
+
157
+ def from_map(self, m: dict = None):
158
+ m = m or dict()
159
+ if m.get('Name') is not None:
160
+ self.any = m.get('Name')
161
+ return self
162
+
163
+
137
164
  class ComplexRequest(TeaModel):
138
165
  def __init__(
139
166
  self,
@@ -146,7 +173,11 @@ class ComplexRequest(TeaModel):
146
173
  part: List[ComplexRequestPart] = None,
147
174
  complex_list: List[List[List[ComplexRequestComplexList]]] = None,
148
175
  complex_list_1: List[List[Dict[str, str]]] = None,
176
+ complex_list_2: List[List[List[ComplexRequestComplexList2]]] = None,
149
177
  from_: str = None,
178
+ self_: str = None,
179
+ print: str = None,
180
+ exec: str = None,
150
181
  ):
151
182
  self.access_key = access_key
152
183
  # Body
@@ -161,8 +192,15 @@ class ComplexRequest(TeaModel):
161
192
  self.part = part
162
193
  self.complex_list = complex_list
163
194
  self.complex_list_1 = complex_list_1
195
+ self.complex_list_2 = complex_list_2
164
196
  # test keywords
165
197
  self.from_ = from_
198
+ # test keywords
199
+ self.self = self_
200
+ # test keywords
201
+ self.print = print
202
+ # test keywords
203
+ self.exec = exec
166
204
 
167
205
  def validate(self):
168
206
  self.validate_required(self.access_key, 'access_key')
@@ -187,7 +225,17 @@ class ComplexRequest(TeaModel):
187
225
  if k2:
188
226
  k2.validate()
189
227
  self.validate_required(self.complex_list_1, 'complex_list_1')
228
+ self.validate_required(self.complex_list_2, 'complex_list_2')
229
+ if self.complex_list_2:
230
+ for k in self.complex_list_2:
231
+ for k1 in k:
232
+ for k2 in k1:
233
+ if k2:
234
+ k2.validate()
190
235
  self.validate_required(self.from_, 'from_')
236
+ self.validate_required(self.self, 'self')
237
+ self.validate_required(self.print, 'print')
238
+ self.validate_required(self.exec, 'exec')
191
239
 
192
240
  def to_map(self):
193
241
  _map = super().to_map()
@@ -223,8 +271,24 @@ class ComplexRequest(TeaModel):
223
271
  result['complexList'].append(l1)
224
272
  if self.complex_list_1 is not None:
225
273
  result['complexList1'] = self.complex_list_1
274
+ result['ComplexList2'] = []
275
+ if self.complex_list_2 is not None:
276
+ for k in self.complex_list_2:
277
+ l1 = []
278
+ for k1 in k:
279
+ l2 = []
280
+ for k2 in k1:
281
+ l2.append(k2.to_map() if k2 else None)
282
+ l1.append(l2)
283
+ result['ComplexList2'].append(l1)
226
284
  if self.from_ is not None:
227
285
  result['from'] = self.from_
286
+ if self.self is not None:
287
+ result['self'] = self.self
288
+ if self.print is not None:
289
+ result['print'] = self.print
290
+ if self.exec is not None:
291
+ result['exec'] = self.exec
228
292
  return result
229
293
 
230
294
  def from_map(self, m: dict = None):
@@ -261,8 +325,25 @@ class ComplexRequest(TeaModel):
261
325
  self.complex_list.append(l1)
262
326
  if m.get('complexList1') is not None:
263
327
  self.complex_list_1 = m.get('complexList1')
328
+ self.complex_list_2 = []
329
+ if m.get('ComplexList2') is not None:
330
+ for k in m.get('ComplexList2'):
331
+ l1 = []
332
+ for k1 in k:
333
+ l2 = []
334
+ for k2 in k1:
335
+ temp_model = ComplexRequestComplexList2()
336
+ l2.append(temp_model.from_map(k2))
337
+ l1.append(l2)
338
+ self.complex_list_2.append(l1)
264
339
  if m.get('from') is not None:
265
340
  self.from_ = m.get('from')
341
+ if m.get('self') is not None:
342
+ self.self = m.get('self')
343
+ if m.get('print') is not None:
344
+ self.print = m.get('print')
345
+ if m.get('exec') is not None:
346
+ self.exec = m.get('exec')
266
347
  return self
267
348
 
268
349
 
@@ -24,7 +24,7 @@ from setuptools import setup, find_packages
24
24
  """
25
25
  setup module for tea_python_tests.
26
26
 
27
- Created on 13/09/2023
27
+ Created on *
28
28
 
29
29
  @author: Alibaba
30
30
  """
@@ -36,7 +36,15 @@ model ComplexRequest = {
36
36
  }
37
37
  ]]](name='complexList'),
38
38
  complexList1: [[map[string]string]],
39
- from: string(name='from', description='test keywords')
39
+ complexList2: [[[
40
+ {
41
+ any?: any(name='Name'),
42
+ }
43
+ ]]](name='ComplexList2'),
44
+ from: string(name='from', description='test keywords'),
45
+ self: string(name='self', description='test keywords'),
46
+ print: string(name='print', description='test keywords'),
47
+ exec: string(name='exec', description='test keywords'),
40
48
  }
41
49
 
42
50
  async function hello(request: object, strs: [ string ]): [ string ] {
@@ -14,6 +14,9 @@ const {
14
14
  _upperFirst,
15
15
  _config,
16
16
  _avoidKeywords,
17
+ _avoidFuncKeywords,
18
+ _avoidClassKeywords,
19
+ _avoidVarKeywords,
17
20
  _modify,
18
21
  _symbol,
19
22
  _toSnakeCase,
@@ -193,8 +196,21 @@ describe('helper tests', function () {
193
196
  });
194
197
 
195
198
  it('_avoidKeywords should be ok', function () {
196
- _config({ keywords: ['key'] });
199
+ _config({
200
+ keywords: {
201
+ general: 'key',
202
+ function: ['function'],
203
+ class: ['class'],
204
+ param_variables: ['var']
205
+ }
206
+ });
197
207
  expect(_avoidKeywords('key')).to.be.eql('key_');
208
+ expect(_avoidFuncKeywords('key')).to.be.eql('key_');
209
+ expect(_avoidFuncKeywords('function')).to.be.eql('function_');
210
+ expect(_avoidClassKeywords('key')).to.be.eql('key_');
211
+ expect(_avoidClassKeywords('class')).to.be.eql('class_');
212
+ expect(_avoidVarKeywords('key')).to.be.eql('key_');
213
+ expect(_avoidVarKeywords('var')).to.be.eql('var_');
198
214
  });
199
215
 
200
216
  it('_modify should be ok', function () {
@@ -220,7 +236,7 @@ describe('helper tests', function () {
220
236
  expect(_symbol('ASSIGN')).to.be.eql('=');
221
237
  });
222
238
 
223
- it('_isSnakeCase should be ok', function() {
239
+ it('_isSnakeCase should be ok', function () {
224
240
  expect(_isSnakeCase('tea_rpc')).to.be.eql(true);
225
241
  expect(_isSnakeCase('tea')).to.be.eql(true);
226
242
  expect(_isSnakeCase('tearpc')).to.be.eql(true);
@@ -157,8 +157,7 @@ describe('Python Generator', function () {
157
157
 
158
158
  it('import should ok', function () {
159
159
  check('import', [
160
- 'tea_python_tests/client.py',
161
- 'setup.py'
160
+ 'tea_python_tests/client.py'
162
161
  ],
163
162
  {
164
163
  python2: {
@@ -173,6 +172,9 @@ describe('Python Generator', function () {
173
172
  }
174
173
  }
175
174
  });
175
+ const expected = fs.readFileSync(path.join(expectedDir, 'import', 'setup.py'), 'utf8');
176
+ const output = fs.readFileSync(path.join(outputDir, 'import', 'setup.py'), 'utf8');
177
+ assert.deepStrictEqual(output.replace(new RegExp('\\d{2}\\/\\d{2}\\/\\d{4}'), '*'), expected);
176
178
  });
177
179
 
178
180
  it('map should ok', function () {
@@ -157,8 +157,7 @@ describe('Python Generator', function () {
157
157
 
158
158
  it('import should ok', function () {
159
159
  check('import', [
160
- 'tea_python_tests/client.py',
161
- 'setup.py'
160
+ 'tea_python_tests/client.py'
162
161
  ],
163
162
  {
164
163
  python: {
@@ -179,6 +178,9 @@ describe('Python Generator', function () {
179
178
  ]
180
179
  }
181
180
  });
181
+ const expected = fs.readFileSync(path.join(expectedDir, 'import', 'setup.py'), 'utf8');
182
+ const output = fs.readFileSync(path.join(outputDir, 'import', 'setup.py'), 'utf8');
183
+ assert.deepStrictEqual(output.replace(new RegExp('\\d{2}\\/\\d{2}\\/\\d{4}'), '*'), expected);
182
184
  });
183
185
 
184
186
  it('map should ok', function () {
@@ -28,8 +28,8 @@ describe('client resolver should be ok', function () {
28
28
  it('resolve should be ok', function () {
29
29
  const combinator = new Combinator(Object.assign(_deepClone(config), {
30
30
  package: 'test', model: { dir: 'Models' }
31
- }), { });
32
- const code = new ClientResolver({moduleBody: { nodes: [] }}, combinator, {});
31
+ }), {});
32
+ const code = new ClientResolver({ moduleBody: { nodes: [] } }, combinator, {});
33
33
  mm(code, 'initAnnotation', function () { return; });
34
34
  mm(code, 'resolveProps', function () { return; });
35
35
  mm(code.combinator, 'addInclude', function (className) { return className; });
@@ -83,7 +83,7 @@ describe('client resolver should be ok', function () {
83
83
  }), {});
84
84
  const code = new ClientResolver({}, combinator, {});
85
85
  const funcItem = new FuncItem();
86
-
86
+
87
87
  mm(code.combinator, 'addInclude', function (className) {
88
88
  return className;
89
89
  });