@darabonba/python-generator 2.0.9 → 2.0.10

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.
Files changed (156) hide show
  1. package/lib/builtin.js +12 -3
  2. package/lib/generator.js +234 -235
  3. package/lib/helper.js +237 -5
  4. package/package.json +1 -1
  5. package/tests/expected/alias/setup.py +17 -13
  6. package/tests/expected/alias/tea_python_tests/client.py +6 -6
  7. package/tests/expected/annotation/tea_python_tests/client.py +4 -4
  8. package/tests/expected/annotation/tea_python_tests/models/__init__.py +0 -2
  9. package/tests/expected/annotation/tea_python_tests/models/_test.py +1 -1
  10. package/tests/expected/api/tea_python_tests/client.py +4 -4
  11. package/tests/expected/builtin/tea_python_tests/client.py +18 -16
  12. package/tests/expected/comment/tea_python_tests/client.py +6 -5
  13. package/tests/expected/comment/tea_python_tests/models/__init__.py +0 -2
  14. package/tests/expected/comment/tea_python_tests/models/_test_1.py +2 -1
  15. package/tests/expected/comment/tea_python_tests/models/_test_2.py +1 -1
  16. package/tests/expected/comment/tea_python_tests/models/_test_3.py +1 -1
  17. package/tests/expected/complex/tea_python_tests/client.py +17 -16
  18. package/tests/expected/complex/tea_python_tests/exceptions/__init__.py +0 -2
  19. package/tests/expected/complex/tea_python_tests/exceptions/_err_1.py +2 -1
  20. package/tests/expected/complex/tea_python_tests/exceptions/_err_2.py +1 -1
  21. package/tests/expected/complex/tea_python_tests/models/__init__.py +0 -2
  22. package/tests/expected/complex/tea_python_tests/models/_complex_request.py +7 -6
  23. package/tests/expected/complex/tea_python_tests/models/_response.py +2 -2
  24. package/tests/expected/const/tea_python_tests/client.py +0 -2
  25. package/tests/expected/empty/tea_python_tests/client.py +0 -2
  26. package/tests/expected/exec/tea_python_tests/exec_client.py +3 -2
  27. package/tests/expected/function/tea_python_tests/client.py +2 -1
  28. package/tests/expected/import/setup.py +4 -2
  29. package/tests/expected/import/tea_python_tests/client.py +4 -3
  30. package/tests/expected/map/tea_python_tests/client.py +3 -3
  31. package/tests/expected/model/tea_python_tests/client.py +0 -2
  32. package/tests/expected/model/tea_python_tests/exceptions/__init__.py +0 -2
  33. package/tests/expected/model/tea_python_tests/exceptions/_main_file.py +3 -2
  34. package/tests/expected/model/tea_python_tests/models/__init__.py +0 -2
  35. package/tests/expected/model/tea_python_tests/models/_class.py +1 -1
  36. package/tests/expected/model/tea_python_tests/models/_m.py +2 -2
  37. package/tests/expected/model/tea_python_tests/models/_main_file.py +2 -2
  38. package/tests/expected/model/tea_python_tests/models/_model.py +1 -1
  39. package/tests/expected/model/tea_python_tests/models/_my_model.py +6 -5
  40. package/tests/expected/modelConfig/tea_python_tests/client.py +0 -2
  41. package/tests/expected/modelConfig/tea_python_tests/exceptions/__init__.py +0 -2
  42. package/tests/expected/modelConfig/tea_python_tests/exceptions/_main_file.py +3 -2
  43. package/tests/expected/modelConfig/tea_python_tests/models/__init__.py +0 -2
  44. package/tests/expected/modelConfig/tea_python_tests/models/_class.py +1 -1
  45. package/tests/expected/modelConfig/tea_python_tests/models/_m.py +2 -2
  46. package/tests/expected/modelConfig/tea_python_tests/models/_main_file.py +2 -2
  47. package/tests/expected/modelConfig/tea_python_tests/models/_model.py +1 -1
  48. package/tests/expected/modelConfig/tea_python_tests/models/_my_model.py +6 -5
  49. package/tests/expected/multi/tea_python_tests/api.py +5 -5
  50. package/tests/expected/multi/tea_python_tests/api_models/__init__.py +0 -2
  51. package/tests/expected/multi/tea_python_tests/api_models/_test_model_dir_2.py +1 -1
  52. package/tests/expected/multi/tea_python_tests/client.py +4 -3
  53. package/tests/expected/multi/tea_python_tests/exceptions/__init__.py +0 -2
  54. package/tests/expected/multi/tea_python_tests/exceptions/_err.py +1 -1
  55. package/tests/expected/multi/tea_python_tests/lib/util.py +0 -1
  56. package/tests/expected/multi/tea_python_tests/model/user.py +3 -2
  57. package/tests/expected/multi/tea_python_tests/model/user_exceptions/__init__.py +0 -2
  58. package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err.py +1 -1
  59. package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err_1.py +1 -1
  60. package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err_2.py +1 -1
  61. package/tests/expected/multi/tea_python_tests/model/user_models/__init__.py +0 -2
  62. package/tests/expected/multi/tea_python_tests/model/user_models/_base_info.py +1 -1
  63. package/tests/expected/multi/tea_python_tests/model/user_models/_info.py +1 -1
  64. package/tests/expected/multi/tea_python_tests/models/__init__.py +0 -2
  65. package/tests/expected/multi/tea_python_tests/models/_test_model_dir.py +3 -2
  66. package/tests/expected/statements/tea_python_tests/client.py +3 -3
  67. package/tests/expected/super/tea_python_tests/client.py +2 -2
  68. package/tests/expected/typedef/tea_python_tests/client.py +5 -5
  69. package/tests/expected/typedef/tea_python_tests/models/__init__.py +0 -2
  70. package/tests/expected/typedef/tea_python_tests/models/_m.py +3 -3
  71. package/tests/fixtures/alias/Darafile +5 -4
  72. package/tests/fixtures/complex/libraries/import.dara +11 -0
  73. package/tests/fixtures/complex/main.dara +2 -2
  74. package/tests/main.tests.js +26 -23
  75. package/tests/output/alias/setup.py +15 -11
  76. package/tests/output/alias/tea_python_tests/client.py +6 -6
  77. package/tests/output/annotation/setup.py +6 -4
  78. package/tests/output/annotation/tea_python_tests/client.py +4 -4
  79. package/tests/output/annotation/tea_python_tests/models/__init__.py +0 -2
  80. package/tests/output/annotation/tea_python_tests/models/_test.py +1 -1
  81. package/tests/output/api/setup.py +6 -4
  82. package/tests/output/api/tea_python_tests/client.py +4 -4
  83. package/tests/output/builtin/setup.py +6 -4
  84. package/tests/output/builtin/tea_python_tests/client.py +18 -16
  85. package/tests/output/comment/setup.py +6 -4
  86. package/tests/output/comment/tea_python_tests/client.py +6 -5
  87. package/tests/output/comment/tea_python_tests/models/__init__.py +0 -2
  88. package/tests/output/comment/tea_python_tests/models/_test_1.py +2 -1
  89. package/tests/output/comment/tea_python_tests/models/_test_2.py +1 -1
  90. package/tests/output/comment/tea_python_tests/models/_test_3.py +1 -1
  91. package/tests/output/complex/setup.py +6 -4
  92. package/tests/output/complex/tea_python_tests/client.py +17 -16
  93. package/tests/output/complex/tea_python_tests/exceptions/__init__.py +0 -2
  94. package/tests/output/complex/tea_python_tests/exceptions/_err_1.py +2 -1
  95. package/tests/output/complex/tea_python_tests/exceptions/_err_2.py +1 -1
  96. package/tests/output/complex/tea_python_tests/models/__init__.py +0 -2
  97. package/tests/output/complex/tea_python_tests/models/_complex_request.py +7 -6
  98. package/tests/output/complex/tea_python_tests/models/_response.py +2 -2
  99. package/tests/output/const/setup.py +6 -4
  100. package/tests/output/const/tea_python_tests/client.py +0 -2
  101. package/tests/output/empty/setup.py +6 -4
  102. package/tests/output/empty/tea_python_tests/client.py +0 -2
  103. package/tests/output/exec/setup.py +6 -4
  104. package/tests/output/exec/tea_python_tests/exec_client.py +3 -2
  105. package/tests/output/function/setup.py +6 -4
  106. package/tests/output/function/tea_python_tests/client.py +2 -1
  107. package/tests/output/import/setup.py +5 -3
  108. package/tests/output/import/tea_python_tests/client.py +4 -3
  109. package/tests/output/map/setup.py +6 -4
  110. package/tests/output/map/tea_python_tests/client.py +3 -3
  111. package/tests/output/model/setup.py +6 -4
  112. package/tests/output/model/tea_python_tests/client.py +0 -2
  113. package/tests/output/model/tea_python_tests/exceptions/__init__.py +0 -2
  114. package/tests/output/model/tea_python_tests/exceptions/_main_file.py +3 -2
  115. package/tests/output/model/tea_python_tests/models/__init__.py +0 -2
  116. package/tests/output/model/tea_python_tests/models/_class.py +1 -1
  117. package/tests/output/model/tea_python_tests/models/_m.py +2 -2
  118. package/tests/output/model/tea_python_tests/models/_main_file.py +2 -2
  119. package/tests/output/model/tea_python_tests/models/_model.py +1 -1
  120. package/tests/output/model/tea_python_tests/models/_my_model.py +6 -5
  121. package/tests/output/modelConfig/setup.py +6 -4
  122. package/tests/output/modelConfig/tea_python_tests/client.py +0 -2
  123. package/tests/output/modelConfig/tea_python_tests/exceptions/__init__.py +0 -2
  124. package/tests/output/modelConfig/tea_python_tests/exceptions/_main_file.py +3 -2
  125. package/tests/output/modelConfig/tea_python_tests/models/__init__.py +0 -2
  126. package/tests/output/modelConfig/tea_python_tests/models/_class.py +1 -1
  127. package/tests/output/modelConfig/tea_python_tests/models/_m.py +2 -2
  128. package/tests/output/modelConfig/tea_python_tests/models/_main_file.py +2 -2
  129. package/tests/output/modelConfig/tea_python_tests/models/_model.py +1 -1
  130. package/tests/output/modelConfig/tea_python_tests/models/_my_model.py +6 -5
  131. package/tests/output/multi/setup.py +5 -3
  132. package/tests/output/multi/tea_python_tests/api.py +5 -5
  133. package/tests/output/multi/tea_python_tests/api_models/__init__.py +0 -2
  134. package/tests/output/multi/tea_python_tests/api_models/_test_model_dir_2.py +1 -1
  135. package/tests/output/multi/tea_python_tests/client.py +4 -3
  136. package/tests/output/multi/tea_python_tests/exceptions/__init__.py +0 -2
  137. package/tests/output/multi/tea_python_tests/exceptions/_err.py +1 -1
  138. package/tests/output/multi/tea_python_tests/lib/util.py +0 -1
  139. package/tests/output/multi/tea_python_tests/model/user.py +3 -2
  140. package/tests/output/multi/tea_python_tests/model/user_exceptions/__init__.py +0 -2
  141. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err.py +1 -1
  142. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_1.py +1 -1
  143. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_2.py +1 -1
  144. package/tests/output/multi/tea_python_tests/model/user_models/__init__.py +0 -2
  145. package/tests/output/multi/tea_python_tests/model/user_models/_base_info.py +1 -1
  146. package/tests/output/multi/tea_python_tests/model/user_models/_info.py +1 -1
  147. package/tests/output/multi/tea_python_tests/models/__init__.py +0 -2
  148. package/tests/output/multi/tea_python_tests/models/_test_model_dir.py +3 -2
  149. package/tests/output/statements/setup.py +6 -4
  150. package/tests/output/statements/tea_python_tests/client.py +3 -3
  151. package/tests/output/super/setup.py +6 -4
  152. package/tests/output/super/tea_python_tests/client.py +2 -2
  153. package/tests/output/typedef/setup.py +5 -3
  154. package/tests/output/typedef/tea_python_tests/client.py +5 -5
  155. package/tests/output/typedef/tea_python_tests/models/__init__.py +0 -2
  156. package/tests/output/typedef/tea_python_tests/models/_m.py +3 -3
package/lib/helper.js CHANGED
@@ -11,6 +11,23 @@ const keywords = [
11
11
  'lambda', 'nonlocal', 'not', 'or', 'pass',
12
12
  'raise', 'return', 'try', 'while', 'with', 'yield'
13
13
  ];
14
+ // 定义标准库模块列表(Python 3.x常用标准库)
15
+ const standardLibraries = new Set([
16
+ '__future__', 'abc', 'argparse', 'ast', 'asyncio', 'base64', 'bisect',
17
+ 'builtins', 'calendar', 'collections', 'concurrent', 'configparser',
18
+ 'contextlib', 'copy', 'csv', 'datetime', 'decimal', 'difflib',
19
+ 'email', 'enum', 'errno', 'faulthandler', 'fileinput', 'fnmatch',
20
+ 'fractions', 'functools', 'gc', 'glob', 'gzip', 'hashlib', 'heapq',
21
+ 'hmac', 'html', 'http', 'importlib', 'inspect', 'io', 'ipaddress',
22
+ 'itertools', 'json', 'keyword', 'linecache', 'locale', 'logging',
23
+ 'lzma', 'math', 'mimetypes', 'multiprocessing', 'numbers', 'operator',
24
+ 'os', 'pathlib', 'pickle', 'platform', 'pprint', 'queue', 'random',
25
+ 're', 'reprlib', 'secrets', 'shlex', 'shutil', 'signal', 'socket',
26
+ 'sqlite3', 'ssl', 'statistics', 'string', 'subprocess', 'sys',
27
+ 'tarfile', 'tempfile', 'textwrap', 'threading', 'time', 'timeit',
28
+ 'traceback', 'types', 'typing', 'unittest', 'urllib', 'uuid',
29
+ 'warnings', 'weakref', 'xml', 'zipfile', 'zlib'
30
+ ]);
14
31
 
15
32
  const builtinModels = [
16
33
  '$Request', '$Response', '$Error', '$SSEEvent', '$Model',
@@ -18,6 +35,8 @@ const builtinModels = [
18
35
  '$ResponseError', '$FileField'
19
36
  ];
20
37
 
38
+ const words = ['SSE'];
39
+
21
40
  const CORE = 'Dara';
22
41
  const REQUEST = '_request';
23
42
  const RESPONSE = '_response';
@@ -192,7 +211,7 @@ function _camelCase(str, split = '_') {
192
211
  // 如果没有下划线,对整个字符串首字母大写
193
212
  str = _upperFirst(str);
194
213
  }
195
-
214
+
196
215
  return str;
197
216
  }
198
217
 
@@ -202,6 +221,11 @@ function _snakeCase(str) {
202
221
  }
203
222
  let res = '';
204
223
  let tmp = '';
224
+ words.forEach(word => {
225
+ // 只匹配驼峰词前缀,不破坏开头
226
+ const regex = new RegExp(word + '(?=[A-Z0-9])', 'g');
227
+ str = str.replace(regex, _upperFirst(word.toLowerCase()));
228
+ });
205
229
  for (const c of str) {
206
230
  if (/[A-Z|0-9]/.test(c)) {
207
231
  tmp += c;
@@ -258,12 +282,12 @@ function _isBuiltinModel(name) {
258
282
  }
259
283
 
260
284
  function _isDefault(expr) {
261
- if(expr.type !== 'call' || expr.left.type !== 'method_call') {
285
+ if (expr.type !== 'call' || expr.left.type !== 'method_call') {
262
286
  return false;
263
287
  }
264
288
  const name = _name(expr.left.id);
265
289
 
266
- if(name !== '$default') {
290
+ if (name !== '$default') {
267
291
  return false;
268
292
  }
269
293
 
@@ -296,7 +320,7 @@ function _type(name) {
296
320
  return 'int';
297
321
  }
298
322
 
299
- if(name === 'float' || name === 'double') {
323
+ if (name === 'float' || name === 'double') {
300
324
  return 'float';
301
325
  }
302
326
 
@@ -395,7 +419,7 @@ function _escape(str) {
395
419
  }
396
420
 
397
421
  function _removeFilesInDirectory(directoryPath) {
398
- if(!fs.existsSync(directoryPath)) {
422
+ if (!fs.existsSync(directoryPath)) {
399
423
  return;
400
424
  }
401
425
  const files = fs.readdirSync(directoryPath);
@@ -412,6 +436,212 @@ function _removeFilesInDirectory(directoryPath) {
412
436
  }
413
437
  }
414
438
 
439
+ /**
440
+ * 按照Python PEP 8标准对imports进行排序
441
+ * @param {Array} imports - import对象数组
442
+ * @returns {Array} 排序后的imports数组
443
+ */
444
+ function _sortImports(imports) {
445
+ function isStandardLibrary(packageName) {
446
+ if (!packageName) { return false; }
447
+
448
+ // 处理子模块,如 os.path -> os
449
+ const rootModule = packageName.split('.')[0];
450
+ return standardLibraries.has(rootModule);
451
+ }
452
+
453
+ function isThirdPartyLibrary(packageName) {
454
+ if (!packageName) { return false; }
455
+
456
+ // 不是标准库且不是相对导入(不以.开头)
457
+ return !isStandardLibrary(packageName) && !packageName.startsWith('.');
458
+ }
459
+
460
+ function isLocalImport(packageName) {
461
+ if (!packageName) { return false; }
462
+
463
+ // 以.开头的相对导入,或者看起来像本地模块的导入
464
+ return packageName.startsWith('.') ||
465
+ (!isStandardLibrary(packageName) && !isThirdPartyLibrary(packageName));
466
+ }
467
+
468
+ function getImportPriority(importObj) {
469
+ const { packageName, className } = importObj;
470
+
471
+ // 1. __future__ imports (最高优先级)
472
+ if (packageName === '__future__') {
473
+ return 1;
474
+ }
475
+
476
+ // 2. 标准库 import 语句
477
+ if (!packageName && isStandardLibrary(className)) {
478
+ return 2;
479
+ }
480
+
481
+ // 3. 标准库 from...import 语句
482
+ if (packageName && isStandardLibrary(packageName)) {
483
+ return 3;
484
+ }
485
+
486
+ // 4. 第三方库 import 语句
487
+ if (!packageName && isThirdPartyLibrary(className)) {
488
+ return 4;
489
+ }
490
+
491
+ // 5. 第三方库 from...import 语句
492
+ if (packageName && isThirdPartyLibrary(packageName)) {
493
+ return 5;
494
+ }
495
+
496
+ // 6. 本地/相对 import 语句
497
+ if (!packageName && isLocalImport(className)) {
498
+ return 6;
499
+ }
500
+
501
+ // 7. 本地/相对 from...import 语句
502
+ if (packageName && isLocalImport(packageName)) {
503
+ return 7;
504
+ }
505
+
506
+ // 8. 其他情况
507
+ return 8;
508
+ }
509
+
510
+
511
+ // 生成排序键
512
+ function getSortKey(importObj) {
513
+ const { packageName, className } = importObj;
514
+ const priority = getImportPriority(importObj);
515
+
516
+ // 构建排序键:优先级 + 包名 + 类名
517
+ const sortPackage = packageName || '';
518
+ const sortClass = className || '';
519
+
520
+ return `${priority.toString().padStart(2, '0')}_${sortPackage}_${sortClass}`;
521
+ }
522
+
523
+ //合并同一包的from imports
524
+ function mergeFromImportsByPackage(imports) {
525
+ const packageGroups = new Map();
526
+ const nonFromImports = [];
527
+
528
+ for (const importObj of imports) {
529
+ if (importObj.packageName) {
530
+ if (!packageGroups.has(importObj.packageName)) {
531
+ packageGroups.set(importObj.packageName, []);
532
+ }
533
+ packageGroups.get(importObj.packageName).push(importObj);
534
+ } else {
535
+ nonFromImports.push(importObj);
536
+ }
537
+ }
538
+
539
+ const mergedImports = [...nonFromImports];
540
+ for (const [packageName, packageImports] of packageGroups) {
541
+ if (packageImports.length === 1) {
542
+ mergedImports.push(packageImports[0]);
543
+ } else {
544
+ const canMerge = packageImports.every(imp => !imp.aliasName);
545
+
546
+ if (canMerge) {
547
+ const classNames = packageImports.map(imp => imp.className).sort();
548
+ mergedImports.push({
549
+ packageName: packageName,
550
+ className: classNames.join(', '),
551
+ aliasName: '',
552
+ _isMerged: true
553
+ });
554
+ } else {
555
+ mergedImports.push(...packageImports);
556
+ }
557
+ }
558
+ }
559
+
560
+ return mergedImports;
561
+ }
562
+
563
+
564
+ const importMap = new Map();
565
+ for (const importObj of imports) {
566
+ const key = `${importObj.packageName}|${importObj.className}|${importObj.aliasName}`;
567
+
568
+ if (importMap.has(key)) {
569
+ continue;
570
+ }
571
+ importMap.set(key, importObj);
572
+ }
573
+
574
+
575
+ const mergedImports = mergeFromImportsByPackage(Array.from(importMap.values()));
576
+
577
+ // 对imports进行排序
578
+ const sortedImports = [...mergedImports].sort((a, b) => {
579
+ const keyA = getSortKey(a);
580
+ const keyB = getSortKey(b);
581
+ return keyA.localeCompare(keyB);
582
+ });
583
+
584
+ return sortedImports;
585
+ }
586
+
587
+ // 辅助函数:将排序后的导入转换为Python代码字符串
588
+ function _importsToString(sortedImports) {
589
+ const lines = [];
590
+ let lastPriority = -1;
591
+
592
+ // 内部函数需要访问外部的getImportPriority
593
+ function getImportPriority(importObj) {
594
+ const { packageName, className } = importObj;
595
+
596
+ function isStandardLibrary(packageName) {
597
+ if (!packageName) { return false; }
598
+ const rootModule = packageName.split('.')[0];
599
+ return standardLibraries.has(rootModule);
600
+ }
601
+
602
+ if (packageName === '__future__') { return 1; }
603
+ if (!packageName && isStandardLibrary(className)) { return 2; }
604
+ if (packageName && isStandardLibrary(packageName)) { return 3; }
605
+ if (!packageName && !isStandardLibrary(className)) { return 4; }
606
+ if (packageName && !isStandardLibrary(packageName)) { return 5; }
607
+ return 6;
608
+ }
609
+
610
+ sortedImports.forEach(importObj => {
611
+ const { packageName, className, aliasName } = importObj;
612
+ const currentPriority = getImportPriority(importObj);
613
+
614
+ // 在不同优先级组之间添加空行
615
+ if (lastPriority !== -1 && currentPriority !== lastPriority) {
616
+ lines.push('');
617
+ }
618
+
619
+ // 生成import语句
620
+ let importLine;
621
+ if (packageName) {
622
+ // from...import 语句
623
+ if (aliasName) {
624
+ importLine = `from ${packageName} import ${className} as ${aliasName}`;
625
+ } else {
626
+ importLine = `from ${packageName} import ${className}`;
627
+ }
628
+ } else {
629
+ // import 语句
630
+ if (aliasName) {
631
+ importLine = `import ${className} as ${aliasName}`;
632
+ } else {
633
+ importLine = `import ${className}`;
634
+ }
635
+ }
636
+
637
+ lines.push(importLine);
638
+ lastPriority = currentPriority;
639
+ });
640
+
641
+ return lines.join('\n');
642
+ }
643
+
644
+
415
645
  module.exports = {
416
646
  _removeFilesInDirectory,
417
647
  _name,
@@ -433,6 +663,8 @@ module.exports = {
433
663
  _type,
434
664
  _getImport,
435
665
  _adaptedQuotes,
666
+ _sortImports,
667
+ _importsToString,
436
668
  CORE,
437
669
  REQUEST,
438
670
  RESPONSE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darabonba/python-generator",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "The darabonba generator for Python",
5
5
  "main": "lib/generator.js",
6
6
  "directories": {
@@ -22,25 +22,27 @@ import os
22
22
  from setuptools import setup, find_packages
23
23
 
24
24
  """
25
- setup module for tea_python_tests.
25
+ setup module for tea-python-tests.
26
26
 
27
27
  Created on *
28
28
 
29
- @author: Alibaba
29
+ @author: AlibabaCloud SDK Team
30
30
  """
31
31
 
32
32
  PACKAGE = "tea_python_tests"
33
- NAME = "tea_python_tests"
34
- DESCRIPTION = ""
35
- AUTHOR = "Alibaba"
36
- AUTHOR_EMAIL = "sdk-team@alibabacloud.com"
37
- URL = "https://github.com/"
33
+ NAME = "tea-python-tests"
34
+ DESCRIPTION = "Generate setup.py"
35
+ AUTHOR = "AlibabaCloud SDK Team"
36
+ AUTHOR_EMAIL = "sdkteam@alibabacloud.com"
37
+ URL = "https://github.com/dara"
38
38
  VERSION = __import__(PACKAGE).__version__
39
39
  REQUIRES = [
40
- "alibabacloud-tea>=1.0.0",
41
- "source==0.0.1",
42
- "import==1.1.2",
43
- "alibabacloud_tea_util==0.3.11"
40
+ "darabonba-core>=1.0.0, <2.0.0",
41
+ "source>=0.0.1, <1.0.0",
42
+ "import>=1.1.2, <2.0.0",
43
+ "alibabacloud_tea_util>=0.3.11, <1.0.0",
44
+ "xxx1>=0.0.1, <1.0.0",
45
+ "xxx2>=0.0.1, <1.0.0"
44
46
  ]
45
47
 
46
48
  LONG_DESCRIPTION = ''
@@ -63,17 +65,19 @@ setup(
63
65
  include_package_data=True,
64
66
  platforms="any",
65
67
  install_requires=REQUIRES,
66
- python_requires=">=3.6",
68
+ python_requires=">=3.7",
67
69
  classifiers=(
68
70
  "Development Status :: 4 - Beta",
69
71
  "Intended Audience :: Developers",
70
72
  "License :: OSI Approved :: Apache Software License",
71
73
  "Programming Language :: Python",
72
74
  "Programming Language :: Python :: 3",
73
- "Programming Language :: Python :: 3.6",
74
75
  "Programming Language :: Python :: 3.7",
75
76
  "Programming Language :: Python :: 3.8",
76
77
  "Programming Language :: Python :: 3.9",
78
+ "Programming Language :: Python :: 3.10",
79
+ "Programming Language :: Python :: 3.11",
80
+ "Programming Language :: Python :: 3.12",
77
81
  "Topic :: Software Development"
78
82
  )
79
83
  )
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from Import.client import Client as ImportClient
5
- from Source.client import Client as SourceClient
6
- from Alias.alias_client import AliasClient
7
- from alias_source.source_client import SourceClient as AliasSourceSourceClient
8
- from alias_symbol.client import Client as AliasSymbolClient
9
- from alias_symbol import models as alias_symbol_models
10
4
 
5
+ from alias_source.source_client import SourceClient as AliasSourceSourceClient
6
+ from alias_symbol import models as alias_symbol_models
7
+ from alias_symbol.client import Client as AliasSymbolClient
8
+ from Alias.alias_client import AliasClient
9
+ from Import.client import Client as ImportClient
10
+ from Source.client import Client as SourceClient
11
11
 
12
12
 
13
13
 
@@ -1,11 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.core import DaraCore
5
- from darabonba.exceptions import UnretryableException
6
- from darabonba.policy.retry import RetryPolicyContext
7
- from darabonba.request import DaraRequest
8
4
 
5
+ from darabonba.core import DaraCore
6
+ from darabonba.exceptions import UnretryableException
7
+ from darabonba.policy.retry import RetryPolicyContext
8
+ from darabonba.request import DaraRequest
9
9
 
10
10
  """
11
11
  * @remarks
@@ -2,8 +2,6 @@
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
4
 
5
-
6
-
7
5
  from ._test import Test
8
6
 
9
7
  __all__ = [
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.model import DaraModel
5
4
 
5
+ from darabonba.model import DaraModel
6
6
 
7
7
  """
8
8
  * @remarks
@@ -1,11 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.core import DaraCore
5
- from darabonba.request import DaraRequest
6
- from darabonba.exceptions import UnretryableException
7
- from darabonba.policy.retry import RetryPolicyContext
8
4
 
5
+ from darabonba.core import DaraCore
6
+ from darabonba.exceptions import UnretryableException
7
+ from darabonba.policy.retry import RetryPolicyContext
8
+ from darabonba.request import DaraRequest
9
9
 
10
10
  class Client:
11
11
  def __init__(self):
@@ -1,23 +1,25 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- import base64
5
- from darabonba.utils.bytes import Bytes as DaraBytes
6
- from darabonba.date import Date as DaraDate
7
- import os
8
- from darabonba.file import File as DaraFile
9
- from darabonba.utils.form import Form as DaraForm
10
- from darabonba.core import DaraCore as DaraCore
11
- import json
12
- import logging
13
- import random
14
- import math
15
- from darabonba.utils.stream import Stream as DaraStream
16
- from darabonba.url import Url as DaraURL
17
- from darabonba.utils.xml import XML as DaraXML
18
- import sys
4
+
5
+ import base64
6
+ import json
7
+ import logging
8
+ import math
9
+ import os
10
+ import random
11
+ import sys
12
+
19
13
  from typing import List, Any
20
14
 
15
+ from darabonba.core import DaraCore as DaraCore
16
+ from darabonba.date import Date as DaraDate
17
+ from darabonba.file import File as DaraFile
18
+ from darabonba.url import Url as DaraURL
19
+ from darabonba.utils.bytes import Bytes as DaraBytes
20
+ from darabonba.utils.form import Form as DaraForm
21
+ from darabonba.utils.stream import Stream as DaraStream
22
+ from darabonba.utils.xml import XML as DaraXML
21
23
 
22
24
  class Client:
23
25
 
@@ -675,7 +677,7 @@ class Client:
675
677
  if not DaraCore.is_null(data):
676
678
  ws.write(data)
677
679
 
678
- awiat DaraCore.sleep_async(a)
680
+ await DaraCore.sleep_async(a)
679
681
  default_val = args[0] or args[1]
680
682
  if default_val == b:
681
683
  return
@@ -1,13 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from tea_python_tests import models as main_models
5
- from darabonba.core import DaraCore
6
- from darabonba.exceptions import UnretryableException
7
- from darabonba.policy.retry import RetryPolicyContext
8
- from darabonba.request import DaraRequest
4
+
9
5
  from typing import List, Dict, BinaryIO, Any
10
6
 
7
+ from darabonba.core import DaraCore
8
+ from darabonba.exceptions import UnretryableException
9
+ from darabonba.policy.retry import RetryPolicyContext
10
+ from darabonba.request import DaraRequest
11
+ from tea_python_tests import models as main_models
11
12
 
12
13
  # top comment
13
14
  """
@@ -2,8 +2,6 @@
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
4
 
5
-
6
-
7
5
  from ._test_1 import Test1
8
6
  from ._test_2 import Test2
9
7
  from ._test_3 import Test3
@@ -1,9 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.model import DaraModel
4
+
5
5
  from typing import List
6
6
 
7
+ from darabonba.model import DaraModel
7
8
 
8
9
  # import comment
9
10
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.model import DaraModel
5
4
 
5
+ from darabonba.model import DaraModel
6
6
 
7
7
  """
8
8
  * @remarks
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.model import DaraModel
5
4
 
5
+ from darabonba.model import DaraModel
6
6
 
7
7
  """
8
8
  * @remarks
@@ -1,20 +1,21 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from Source.source_client import SourceClient
5
- from Source import models as source_models
6
- from darabonba.core import DaraCore
7
- from tea_python_tests import models as main_models
8
- from darabonba.exceptions import UnretryableException
9
- from darabonba.policy.retry import RetryPolicyContext
10
- from darabonba.request import DaraRequest
11
- import logging
12
- from darabonba.response import DaraResponse
13
- from darabonba.exceptions import DaraException
14
- from tea_python_tests import exceptions as main_exceptions
15
- from Source import exceptions as source_exceptions
4
+
5
+ import logging
6
+
16
7
  from typing import List, Dict, Any
17
8
 
9
+ from darabonba.core import DaraCore
10
+ from darabonba.exceptions import DaraException, UnretryableException
11
+ from darabonba.policy.retry import RetryPolicyContext
12
+ from darabonba.request import DaraRequest
13
+ from darabonba.response import DaraResponse
14
+ from Source import exceptions as source_exceptions
15
+ from Source import models as source_models
16
+ from Source.source_client import SourceClient
17
+ from tea_python_tests import exceptions as main_exceptions
18
+ from tea_python_tests import models as main_models
18
19
 
19
20
  class Client(SourceClient):
20
21
  _protocol: str = None
@@ -226,7 +227,7 @@ class Client(SourceClient):
226
227
  return
227
228
  elif SourceClient.judge_str('test') or False:
228
229
  return source_models.RuntimeObject()
229
- source_client.print_data(DaraCore.to_map(request), '1')
230
+ source_client.print_data_async(DaraCore.to_map(request), '1')
230
231
  self.hello(DaraCore.to_map(request), [
231
232
  '1',
232
233
  '2'
@@ -441,7 +442,7 @@ class Client(SourceClient):
441
442
  return
442
443
  elif SourceClient.judge_str('test') or False:
443
444
  return source_models.RuntimeObject()
444
- source_client.print_data(DaraCore.to_map(request), '1')
445
+ await source_client.print_data_async_async(DaraCore.to_map(request), '1')
445
446
  await self.hello_async(DaraCore.to_map(request), [
446
447
  '1',
447
448
  '2'
@@ -476,7 +477,7 @@ class Client(SourceClient):
476
477
  config_array = [
477
478
  config
478
479
  ]
479
- source_client.print_data(DaraCore.to_map(request), '1')
480
+ source_client.print_data_sse(DaraCore.to_map(request), '1')
480
481
  _request.protocol = 'HTTP'
481
482
  _request.port = 80
482
483
  _request.method = 'GET'
@@ -503,7 +504,7 @@ class Client(SourceClient):
503
504
  config_array = [
504
505
  config
505
506
  ]
506
- source_client.print_data(DaraCore.to_map(request), '1')
507
+ source_client.print_data_sse_async(DaraCore.to_map(request), '1')
507
508
  _request.protocol = 'HTTP'
508
509
  _request.port = 80
509
510
  _request.method = 'GET'
@@ -2,8 +2,6 @@
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
4
 
5
-
6
-
7
5
  from ._err_1 import Err1Exception
8
6
  from ._err_2 import Err2Exception
9
7
 
@@ -1,9 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.exceptions import DaraException
4
+
5
5
  from typing import Dict
6
6
 
7
+ from darabonba.exceptions import DaraException
7
8
 
8
9
  class Err1Exception(DaraException):
9
10
  def __init__(
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
- from darabonba.exceptions import DaraException
5
4
 
5
+ from darabonba.exceptions import DaraException
6
6
 
7
7
  class Err2Exception(DaraException):
8
8
  def __init__(
@@ -2,8 +2,6 @@
2
2
  # This file is auto-generated, don't edit it. Thanks.
3
3
  from __future__ import annotations
4
4
 
5
-
6
-
7
5
  from ._complex_request import ComplexRequest
8
6
  from ._response import Response
9
7
  from ._complex_request import ComplexRequestHeader