@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.
Files changed (152) hide show
  1. package/ChangeLog.md +0 -158
  2. package/lib/builtin.js +818 -0
  3. package/lib/generator.js +2708 -0
  4. package/lib/helper.js +422 -0
  5. package/package.json +6 -5
  6. package/tests/expected/alias/setup.py +79 -0
  7. package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
  8. package/tests/expected/alias/tea_python_tests/client.py +35 -0
  9. package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
  10. package/tests/expected/annotation/tea_python_tests/client.py +93 -0
  11. package/tests/expected/annotation/tea_python_tests/models.py +37 -0
  12. package/tests/expected/api/tea_python_tests/__init__.py +1 -0
  13. package/tests/expected/api/tea_python_tests/client.py +106 -0
  14. package/tests/expected/builtin/tea_python_tests/client.py +685 -0
  15. package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
  16. package/tests/expected/comment/tea_python_tests/client.py +288 -0
  17. package/tests/expected/comment/tea_python_tests/models.py +195 -0
  18. package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
  19. package/tests/expected/complex/tea_python_tests/client.py +1169 -0
  20. package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
  21. package/tests/expected/complex/tea_python_tests/models.py +570 -0
  22. package/tests/expected/const/tea_python_tests/__init__.py +1 -0
  23. package/tests/expected/const/tea_python_tests/client.py +14 -0
  24. package/{src/langs/python/files/setup.py.tmpl → tests/expected/empty/setup.py} +11 -11
  25. package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
  26. package/tests/expected/empty/tea_python_tests/client.py +10 -0
  27. package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
  28. package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
  29. package/tests/expected/function/tea_python_tests/__init__.py +1 -0
  30. package/tests/expected/function/tea_python_tests/client.py +64 -0
  31. package/tests/expected/import/setup.py +78 -0
  32. package/tests/expected/import/tea_python_tests/__init__.py +1 -0
  33. package/tests/expected/import/tea_python_tests/client.py +29 -0
  34. package/tests/expected/map/tea_python_tests/__init__.py +1 -0
  35. package/tests/expected/map/tea_python_tests/client.py +39 -0
  36. package/tests/expected/model/tea_python_tests/__init__.py +1 -0
  37. package/tests/expected/model/tea_python_tests/client.py +10 -0
  38. package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
  39. package/tests/expected/model/tea_python_tests/models.py +780 -0
  40. package/tests/expected/multi/tea_python_tests/api.py +95 -0
  41. package/tests/expected/multi/tea_python_tests/client.py +40 -0
  42. package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
  43. package/tests/expected/multi/tea_python_tests/model/user.py +26 -0
  44. package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
  45. package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
  46. package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
  47. package/tests/expected/statements/tea_python_tests/client.py +86 -0
  48. package/tests/expected/super/tea_python_tests/__init__.py +1 -0
  49. package/tests/expected/super/tea_python_tests/client.py +16 -0
  50. package/tests/expected/typedef/setup.py +77 -0
  51. package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
  52. package/tests/expected/typedef/tea_python_tests/client.py +74 -0
  53. package/tests/expected/typedef/tea_python_tests/models.py +42 -0
  54. package/tests/fixtures/alias/Darafile +11 -0
  55. package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
  56. package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
  57. package/tests/fixtures/builtin/Darafile +6 -0
  58. package/tests/fixtures/builtin/main.dara +333 -0
  59. package/tests/fixtures/complex/libraries/import.dara +18 -11
  60. package/tests/fixtures/complex/main.dara +452 -103
  61. package/tests/fixtures/import/libraries/Darafile +1 -1
  62. package/tests/fixtures/import/pack/Darafile +3 -0
  63. package/tests/fixtures/map/libraries/Darafile +3 -0
  64. package/tests/fixtures/map/libraries/import.dara +4 -0
  65. package/tests/fixtures/map/main.dara +17 -2
  66. package/tests/fixtures/model/.libraries.json +3 -0
  67. package/tests/fixtures/model/Darafile +5 -2
  68. package/tests/fixtures/model/libraries/Darafile +20 -0
  69. package/tests/fixtures/model/libraries/import.dara +27 -0
  70. package/tests/fixtures/model/main.dara +60 -42
  71. package/tests/fixtures/multi/.libraries.json +3 -0
  72. package/tests/fixtures/multi/Darafile +12 -0
  73. package/tests/fixtures/multi/api.dara +20 -0
  74. package/tests/fixtures/multi/lib/util.dara +5 -0
  75. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +68 -0
  76. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
  77. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
  78. package/tests/fixtures/multi/main.dara +32 -0
  79. package/tests/fixtures/multi/model/user.dara +35 -0
  80. package/tests/{python3.tests.js → main.tests.js} +107 -65
  81. package/tests/output/alias/setup.py +79 -0
  82. package/tests/output/alias/tea_python_tests/client.py +35 -0
  83. package/{src/langs/python2/files/setup.py.tmpl → tests/output/annotation/setup.py} +19 -24
  84. package/tests/output/annotation/tea_python_tests/client.py +93 -0
  85. package/tests/output/annotation/tea_python_tests/models.py +37 -0
  86. package/tests/output/api/setup.py +77 -0
  87. package/tests/output/api/tea_python_tests/client.py +106 -0
  88. package/tests/output/builtin/setup.py +77 -0
  89. package/tests/output/builtin/tea_python_tests/client.py +685 -0
  90. package/tests/output/comment/setup.py +77 -0
  91. package/tests/output/comment/tea_python_tests/client.py +288 -0
  92. package/tests/output/comment/tea_python_tests/models.py +195 -0
  93. package/tests/output/complex/setup.py +77 -0
  94. package/tests/output/complex/tea_python_tests/client.py +1169 -0
  95. package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
  96. package/tests/output/complex/tea_python_tests/models.py +570 -0
  97. package/tests/output/const/setup.py +77 -0
  98. package/tests/output/const/tea_python_tests/client.py +14 -0
  99. package/tests/output/empty/setup.py +77 -0
  100. package/tests/output/empty/tea_python_tests/client.py +10 -0
  101. package/tests/output/exec/setup.py +77 -0
  102. package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
  103. package/tests/output/function/setup.py +77 -0
  104. package/tests/output/function/tea_python_tests/client.py +64 -0
  105. package/tests/output/import/setup.py +78 -0
  106. package/tests/output/import/tea_python_tests/client.py +29 -0
  107. package/tests/output/map/setup.py +77 -0
  108. package/tests/output/map/tea_python_tests/client.py +39 -0
  109. package/tests/output/model/setup.py +77 -0
  110. package/tests/output/model/tea_python_tests/client.py +10 -0
  111. package/tests/output/model/tea_python_tests/exceptions.py +28 -0
  112. package/tests/output/model/tea_python_tests/models.py +780 -0
  113. package/tests/output/multi/setup.py +77 -0
  114. package/tests/output/multi/tea_python_tests/api.py +95 -0
  115. package/tests/output/multi/tea_python_tests/client.py +40 -0
  116. package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
  117. package/tests/output/multi/tea_python_tests/model/user.py +26 -0
  118. package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
  119. package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
  120. package/tests/output/statements/setup.py +77 -0
  121. package/tests/output/statements/tea_python_tests/client.py +86 -0
  122. package/tests/output/super/setup.py +77 -0
  123. package/tests/output/super/tea_python_tests/client.py +16 -0
  124. package/tests/output/typedef/setup.py +78 -0
  125. package/tests/output/typedef/tea_python_tests/client.py +74 -0
  126. package/tests/output/typedef/tea_python_tests/models.py +42 -0
  127. package/src/generator.js +0 -231
  128. package/src/langs/common/combinator.js +0 -193
  129. package/src/langs/common/config.js +0 -60
  130. package/src/langs/common/enum.js +0 -179
  131. package/src/langs/common/items.js +0 -551
  132. package/src/langs/common/package_info.js +0 -53
  133. package/src/langs/python/combinator.js +0 -1898
  134. package/src/langs/python/config.js +0 -169
  135. package/src/langs/python/files/.gitignore.tmpl +0 -5
  136. package/src/langs/python/files/__init__.py.tmpl +0 -1
  137. package/src/langs/python/package_info.js +0 -78
  138. package/src/langs/python2/combinator.js +0 -1770
  139. package/src/langs/python2/config.js +0 -162
  140. package/src/langs/python2/files/.gitignore.tmpl +0 -5
  141. package/src/langs/python2/files/__init__.py.tmpl +0 -1
  142. package/src/langs/python2/package_info.js +0 -78
  143. package/src/lib/debug.js +0 -55
  144. package/src/lib/emitter.js +0 -95
  145. package/src/lib/helper.js +0 -207
  146. package/src/resolver/base.js +0 -282
  147. package/src/resolver/client.js +0 -1013
  148. package/src/resolver/model.js +0 -159
  149. package/tests/common.tests.js +0 -244
  150. package/tests/lib.tests.js +0 -269
  151. package/tests/python2.tests.js +0 -283
  152. package/tests/resolver.tests.js +0 -434
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
3
+ from __future__ import annotations
4
+ import sys
5
+ from typing import List
6
+
7
+
8
+ class ExecClient:
9
+
10
+ def __init__(self):
11
+ pass
12
+
13
+ @staticmethod
14
+ def main(
15
+ args: List[str],
16
+ ) -> None:
17
+ pass
18
+
19
+
20
+ if __name__ == '__main__':
21
+ ExecClient.main(sys.argv[1:])
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
3
+ from __future__ import annotations
4
+ from darabonba.core import DaraCore
5
+ from typing import Dict, List
6
+
7
+
8
+ class Client:
9
+ def __init__(self):
10
+ pass
11
+
12
+ @staticmethod
13
+ def hello() -> None:
14
+ return
15
+
16
+ @staticmethod
17
+ def hello_map() -> Dict[str, str]:
18
+ m = {}
19
+ return DaraCore.merge({
20
+ 'key': 'value',
21
+ 'key-1': 'value-1',
22
+ 'key-2': 'value-2',
23
+ '': 'value-3',
24
+ }, m)
25
+
26
+ @staticmethod
27
+ def hello_array_map() -> List[Dict[str, str]]:
28
+ return [
29
+ {
30
+ 'key': 'value'
31
+ }
32
+ ]
33
+
34
+ @staticmethod
35
+ def hello_params(
36
+ a: str,
37
+ b: str,
38
+ ) -> None:
39
+ Client.hello_interface()
40
+ Client.hello_array_map()
41
+
42
+ @staticmethod
43
+ async def hello_params_async(
44
+ a: str,
45
+ b: str,
46
+ ) -> None:
47
+ await Client.hello_interface_async()
48
+ Client.hello_array_map()
49
+
50
+ @staticmethod
51
+ def hello_interface() -> None:
52
+ # interface mode
53
+ raise Exception('Un-implemented')
54
+
55
+ @staticmethod
56
+ async def hello_interface_async() -> None:
57
+ # interface mode
58
+ raise Exception('Un-implemented')
59
+
60
+ def a_params(self) -> None:
61
+ self.hello_params('a', 'b')
62
+
63
+ async def a_params_async(self) -> None:
64
+ await self.hello_params_async('a', 'b')
@@ -0,0 +1,78 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Licensed to the Apache Software Foundation (ASF) under one
4
+ or more contributor license agreements. See the NOTICE file
5
+ distributed with this work for additional information
6
+ regarding copyright ownership. The ASF licenses this file
7
+ to you under the Apache License, Version 2.0 (the
8
+ "License"); you may not use this file except in compliance
9
+ with the License. You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing,
14
+ software distributed under the License is distributed on an
15
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ KIND, either express or implied. See the License for the
17
+ specific language governing permissions and limitations
18
+ under the License.
19
+ """
20
+
21
+ import os
22
+ from setuptools import setup, find_packages
23
+
24
+ """
25
+ setup module for tea_python_tests.
26
+
27
+ Created on *
28
+
29
+ @author: Alibaba
30
+ """
31
+
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/"
38
+ VERSION = __import__(PACKAGE).__version__
39
+ REQUIRES = [
40
+ "darabonba-core>=1.0.0, <2.0.0",
41
+ "alibabacloud_import==0.0.1rc1",
42
+ "alibabacloud_local>=0.0.1, <1.0.0"
43
+ ]
44
+
45
+ LONG_DESCRIPTION = ''
46
+ if os.path.exists('./README.md'):
47
+ with open("README.md", encoding='utf-8') as fp:
48
+ LONG_DESCRIPTION = fp.read()
49
+
50
+ setup(
51
+ name=NAME,
52
+ version=VERSION,
53
+ description=DESCRIPTION,
54
+ long_description=LONG_DESCRIPTION,
55
+ long_description_content_type='text/markdown',
56
+ author=AUTHOR,
57
+ author_email=AUTHOR_EMAIL,
58
+ license="Apache License 2.0",
59
+ url=URL,
60
+ keywords=["tea","python","tests"],
61
+ packages=find_packages(exclude=["tests*"]),
62
+ include_package_data=True,
63
+ platforms="any",
64
+ install_requires=REQUIRES,
65
+ python_requires=">=3.6",
66
+ classifiers=(
67
+ "Development Status :: 4 - Beta",
68
+ "Intended Audience :: Developers",
69
+ "License :: OSI Approved :: Apache Software License",
70
+ "Programming Language :: Python",
71
+ "Programming Language :: Python :: 3",
72
+ "Programming Language :: Python :: 3.6",
73
+ "Programming Language :: Python :: 3.7",
74
+ "Programming Language :: Python :: 3.8",
75
+ "Programming Language :: Python :: 3.9",
76
+ "Topic :: Software Development"
77
+ )
78
+ )
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
3
+ from __future__ import annotations
4
+ from Local import models as local_models
5
+ from Source.source_client import SourceClient
6
+ from Source import models as source_models
7
+ from typing import List
8
+
9
+
10
+
11
+
12
+ class Client:
13
+ _id: List[str] = None
14
+ _str: str = None
15
+ _model: local_models.Local = None
16
+
17
+ def __init__(self):
18
+ pass
19
+
20
+ @staticmethod
21
+ def sample(
22
+ client: SourceClient,
23
+ ) -> None:
24
+ runtime = source_models.RuntimeObject()
25
+ request = source_models.Request(
26
+ accesskey = 'accesskey',
27
+ region = 'region'
28
+ )
29
+ client.print(runtime)
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
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
+
8
+
9
+
10
+
11
+ class Client(SourceClient):
12
+
13
+ def __init__(
14
+ self,
15
+ config: source_models.Config,
16
+ ):
17
+ super().__init__(config)
18
+ a = {
19
+ 'test': 'test'
20
+ }
21
+ c = {
22
+ 'test': 'test'
23
+ }
24
+ self._endpoint_rule = 'central'
25
+ self._endpoint_map = DaraCore.merge({
26
+ 'ap-northeast-1': 'cusanalytic.aliyuncs.com',
27
+ 'ap-south-1': 'cusanalytic.aliyuncs.com',
28
+ 'ap-south-2-test': SourceClient.hello()
29
+ }, a, c)
30
+ b = {
31
+ 'ap-northeast-1': {
32
+ 'ap-south-1': 'cusanalytic.aliyuncs.com'
33
+ },
34
+ 'ap-south-2': SourceClient.hello()
35
+ }
36
+ self._endpoint_map.get('ap-northeast-1')
37
+ self._endpoint_map['ap-northeast-1'] = ''
38
+ self._endpoint_map[config.str_value] = 'str'
39
+ self._endpoint_map.get(config.str_value)
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
3
+ from __future__ import annotations
4
+
5
+
6
+
7
+ class Client:
8
+
9
+ def __init__(self):
10
+ pass
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is auto-generated, don't edit it. Thanks.
3
+ from __future__ import annotations
4
+ from darabonba.exceptions import DaraException
5
+ from tea_python_tests import models as main_models
6
+ from typing import Dict
7
+
8
+
9
+ class MainFileException(DaraException):
10
+ def __init__(
11
+ self,
12
+ message: str = None,
13
+ code: str = None,
14
+ stack: str = None,
15
+ size: int = None,
16
+ data: Dict[str, main_models.Model] = None,
17
+ model: main_models.MainFileModel = None,
18
+ ):
19
+ super().__init__({
20
+ 'message': message,
21
+ 'code': code,
22
+ 'stack': stack,
23
+ })
24
+ self.name = 'MainFileException'
25
+ self.size = size
26
+ self.data = data
27
+ self.model = model
28
+