@darabonba/python-generator 2.0.13 → 2.0.14

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 (112) hide show
  1. package/ChangeLog.md +2 -2
  2. package/lib/generator.js +1 -1
  3. package/package.json +1 -1
  4. package/tests/expected/websocket/tea_python_tests/client.py +20 -0
  5. package/tests/fixtures/websocket/.libraries.json +3 -0
  6. package/tests/fixtures/websocket/Darafile +9 -0
  7. package/tests/fixtures/websocket/libraries/alibabacloud_OpenApiV2_0.1.27/Teafile +21 -0
  8. package/tests/fixtures/websocket/libraries/alibabacloud_OpenApiV2_0.1.27/main.tea +1 -0
  9. package/tests/fixtures/websocket/libraries/alibabacloud_OpenApiV2_0.1.27/utils.dara +1 -0
  10. package/tests/fixtures/websocket/libraries/alibabacloud_OpenApiV2_0.1.27/websocketUtils.dara +9 -0
  11. package/tests/fixtures/websocket/main.dara +8 -0
  12. package/tests/main.tests.js +10 -0
  13. package/tests/output/alias/setup.py +0 -83
  14. package/tests/output/alias/tea_python_tests/client.py +0 -35
  15. package/tests/output/annotation/setup.py +0 -79
  16. package/tests/output/annotation/tea_python_tests/__init__.py +0 -1
  17. package/tests/output/annotation/tea_python_tests/client.py +0 -93
  18. package/tests/output/annotation/tea_python_tests/models/__init__.py +0 -9
  19. package/tests/output/annotation/tea_python_tests/models/_test.py +0 -38
  20. package/tests/output/api/setup.py +0 -79
  21. package/tests/output/api/tea_python_tests/__init__.py +0 -1
  22. package/tests/output/api/tea_python_tests/client.py +0 -106
  23. package/tests/output/builtin/setup.py +0 -79
  24. package/tests/output/builtin/tea_python_tests/__init__.py +0 -1
  25. package/tests/output/builtin/tea_python_tests/client.py +0 -687
  26. package/tests/output/comment/setup.py +0 -79
  27. package/tests/output/comment/tea_python_tests/__init__.py +0 -1
  28. package/tests/output/comment/tea_python_tests/client.py +0 -289
  29. package/tests/output/comment/tea_python_tests/models/__init__.py +0 -13
  30. package/tests/output/comment/tea_python_tests/models/_test_1.py +0 -103
  31. package/tests/output/comment/tea_python_tests/models/_test_2.py +0 -58
  32. package/tests/output/comment/tea_python_tests/models/_test_3.py +0 -64
  33. package/tests/output/complex/setup.py +0 -79
  34. package/tests/output/complex/tea_python_tests/__init__.py +0 -1
  35. package/tests/output/complex/tea_python_tests/client.py +0 -1172
  36. package/tests/output/complex/tea_python_tests/exceptions/__init__.py +0 -11
  37. package/tests/output/complex/tea_python_tests/exceptions/_err_1.py +0 -24
  38. package/tests/output/complex/tea_python_tests/exceptions/_err_2.py +0 -22
  39. package/tests/output/complex/tea_python_tests/models/__init__.py +0 -17
  40. package/tests/output/complex/tea_python_tests/models/_complex_request.py +0 -574
  41. package/tests/output/complex/tea_python_tests/models/_response.py +0 -34
  42. package/tests/output/const/setup.py +0 -79
  43. package/tests/output/const/tea_python_tests/__init__.py +0 -1
  44. package/tests/output/const/tea_python_tests/client.py +0 -12
  45. package/tests/output/empty/setup.py +0 -79
  46. package/tests/output/empty/tea_python_tests/__init__.py +0 -1
  47. package/tests/output/empty/tea_python_tests/client.py +0 -8
  48. package/tests/output/exec/setup.py +0 -79
  49. package/tests/output/exec/tea_python_tests/__init__.py +0 -1
  50. package/tests/output/exec/tea_python_tests/exec_client.py +0 -22
  51. package/tests/output/function/setup.py +0 -79
  52. package/tests/output/function/tea_python_tests/__init__.py +0 -1
  53. package/tests/output/function/tea_python_tests/client.py +0 -77
  54. package/tests/output/import/setup.py +0 -80
  55. package/tests/output/import/tea_python_tests/__init__.py +0 -1
  56. package/tests/output/import/tea_python_tests/client.py +0 -30
  57. package/tests/output/map/setup.py +0 -79
  58. package/tests/output/map/tea_python_tests/__init__.py +0 -1
  59. package/tests/output/map/tea_python_tests/client.py +0 -39
  60. package/tests/output/model/setup.py +0 -79
  61. package/tests/output/model/tea_python_tests/__init__.py +0 -1
  62. package/tests/output/model/tea_python_tests/client.py +0 -8
  63. package/tests/output/model/tea_python_tests/exceptions/__init__.py +0 -9
  64. package/tests/output/model/tea_python_tests/exceptions/_main_file.py +0 -29
  65. package/tests/output/model/tea_python_tests/models/__init__.py +0 -31
  66. package/tests/output/model/tea_python_tests/models/_class.py +0 -23
  67. package/tests/output/model/tea_python_tests/models/_m.py +0 -56
  68. package/tests/output/model/tea_python_tests/models/_main_file.py +0 -73
  69. package/tests/output/model/tea_python_tests/models/_model.py +0 -33
  70. package/tests/output/model/tea_python_tests/models/_my_model.py +0 -786
  71. package/tests/output/modelConfig/setup.py +0 -79
  72. package/tests/output/modelConfig/tea_python_tests/__init__.py +0 -1
  73. package/tests/output/modelConfig/tea_python_tests/client.py +0 -8
  74. package/tests/output/modelConfig/tea_python_tests/exceptions/__init__.py +0 -9
  75. package/tests/output/modelConfig/tea_python_tests/exceptions/_main_file.py +0 -29
  76. package/tests/output/modelConfig/tea_python_tests/models/__init__.py +0 -31
  77. package/tests/output/modelConfig/tea_python_tests/models/_class.py +0 -23
  78. package/tests/output/modelConfig/tea_python_tests/models/_m.py +0 -56
  79. package/tests/output/modelConfig/tea_python_tests/models/_main_file.py +0 -73
  80. package/tests/output/modelConfig/tea_python_tests/models/_model.py +0 -33
  81. package/tests/output/modelConfig/tea_python_tests/models/_my_model.py +0 -750
  82. package/tests/output/multi/setup.py +0 -79
  83. package/tests/output/multi/tea_python_tests/__init__.py +0 -1
  84. package/tests/output/multi/tea_python_tests/api.py +0 -93
  85. package/tests/output/multi/tea_python_tests/api_models/__init__.py +0 -9
  86. package/tests/output/multi/tea_python_tests/api_models/_test_model_dir_2.py +0 -35
  87. package/tests/output/multi/tea_python_tests/client.py +0 -39
  88. package/tests/output/multi/tea_python_tests/exceptions/__init__.py +0 -11
  89. package/tests/output/multi/tea_python_tests/exceptions/_err.py +0 -38
  90. package/tests/output/multi/tea_python_tests/lib/util.py +0 -18
  91. package/tests/output/multi/tea_python_tests/model/user.py +0 -27
  92. package/tests/output/multi/tea_python_tests/model/user_exceptions/__init__.py +0 -13
  93. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err.py +0 -22
  94. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_1.py +0 -54
  95. package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_2.py +0 -18
  96. package/tests/output/multi/tea_python_tests/model/user_models/__init__.py +0 -11
  97. package/tests/output/multi/tea_python_tests/model/user_models/_base_info.py +0 -73
  98. package/tests/output/multi/tea_python_tests/model/user_models/_info.py +0 -82
  99. package/tests/output/multi/tea_python_tests/models/__init__.py +0 -11
  100. package/tests/output/multi/tea_python_tests/models/_test_model_dir.py +0 -84
  101. package/tests/output/statements/setup.py +0 -79
  102. package/tests/output/statements/tea_python_tests/__init__.py +0 -1
  103. package/tests/output/statements/tea_python_tests/client.py +0 -86
  104. package/tests/output/super/setup.py +0 -79
  105. package/tests/output/super/tea_python_tests/__init__.py +0 -1
  106. package/tests/output/super/tea_python_tests/client.py +0 -16
  107. package/tests/output/typedef/setup.py +0 -80
  108. package/tests/output/typedef/tea_python_tests/__init__.py +0 -1
  109. package/tests/output/typedef/tea_python_tests/client.py +0 -74
  110. package/tests/output/typedef/tea_python_tests/models/__init__.py +0 -9
  111. package/tests/output/typedef/tea_python_tests/models/_m.py +0 -45
  112. /package/tests/{output/alias → expected/websocket}/tea_python_tests/__init__.py +0 -0
@@ -1,687 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # This file is auto-generated, don't edit it. Thanks.
3
- from __future__ import annotations
4
-
5
- import base64
6
- import json
7
- import logging
8
- import math
9
- import os
10
- import random
11
- import sys
12
-
13
- from typing import List, Any
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
23
-
24
- class Client:
25
-
26
- def __init__(self):
27
- pass
28
-
29
- @staticmethod
30
- def array_test(
31
- args: List[str],
32
- ) -> None:
33
- if (len(args) > 0) and 'cn-hanghzou' in args:
34
- index = args.index('cn-hanghzou')
35
- region_id = args[index]
36
- all = ','.join(args)
37
- first = args.pop(0)
38
- last = args.pop()
39
- length_1 = args.insert(0, first)
40
- length_2 = args.insert(last)
41
- length_3 = length_1 + length_2
42
- long_str = 'long' + first + last
43
- full_str = ','.join(args)
44
- new_arr = [
45
- 'test'
46
- ]
47
- c_arr = new_arr + args
48
- acs_arr = sorted(new_arr)
49
- desc_arr = sorted(new_arr, reverse=True)
50
- ll_arr = acs_arr + desc_arr
51
- ll_arr.insert(10, 'test')
52
- ll_arr.remove('test')
53
-
54
- @staticmethod
55
- async def array_test_async(
56
- args: List[str],
57
- ) -> None:
58
- if (len(args) > 0) and 'cn-hanghzou' in args:
59
- index = args.index('cn-hanghzou')
60
- region_id = args[index]
61
- all = ','.join(args)
62
- first = args.pop(0)
63
- last = args.pop()
64
- length_1 = args.insert(0, first)
65
- length_2 = args.insert(last)
66
- length_3 = length_1 + length_2
67
- long_str = 'long' + first + last
68
- full_str = ','.join(args)
69
- new_arr = [
70
- 'test'
71
- ]
72
- c_arr = new_arr + args
73
- acs_arr = sorted(new_arr)
74
- desc_arr = sorted(new_arr, reverse=True)
75
- ll_arr = acs_arr + desc_arr
76
- ll_arr.insert(10, 'test')
77
- ll_arr.remove('test')
78
-
79
- @staticmethod
80
- def bytes_test(
81
- args: List[str],
82
- ) -> None:
83
- full_str = ','.join(args)
84
- data = full_str.encode('utf-8')
85
- new_full_str = data.decode('utf-8')
86
- if full_str != new_full_str:
87
- return
88
- hex_str = data.hex()
89
- base_64str = base64.b64encode(data).decode('utf-8')
90
- length = len(data)
91
- obj = data.decode('utf-8')
92
- data_2 = DaraBytes.from_(full_str, 'base64')
93
-
94
- @staticmethod
95
- async def bytes_test_async(
96
- args: List[str],
97
- ) -> None:
98
- full_str = ','.join(args)
99
- data = full_str.encode('utf-8')
100
- new_full_str = data.decode('utf-8')
101
- if full_str != new_full_str:
102
- return
103
- hex_str = data.hex()
104
- base_64str = base64.b64encode(data).decode('utf-8')
105
- length = len(data)
106
- obj = data.decode('utf-8')
107
- data_2 = DaraBytes.from_(full_str, 'base64')
108
-
109
- @staticmethod
110
- def date_test(
111
- args: List[str],
112
- ) -> None:
113
- date = DaraDate('2023-09-12 17:47:31.916000 +0800 UTC')
114
- date_str = date.strftime('%Y-%m-%d %H:%M:%S')
115
- timestamp = date.timestamp()
116
- yesterday = date.sub('day', 1)
117
- one_day = date.diff('day', yesterday)
118
- tomorrow = date.add('day', 1)
119
- two_day = tomorrow.diff('day', date) + one_day
120
- hour = date.hour()
121
- minute = date.minute()
122
- second = date.second()
123
- day_of_month = date.day_of_month()
124
- day_of_week = date.weekday()
125
- week_of_year = date.week_of_year()
126
- month = date.month()
127
- year = date.year()
128
- utc_date = date.UTC()
129
-
130
- @staticmethod
131
- async def date_test_async(
132
- args: List[str],
133
- ) -> None:
134
- date = DaraDate('2023-09-12 17:47:31.916000 +0800 UTC')
135
- date_str = date.strftime('%Y-%m-%d %H:%M:%S')
136
- timestamp = date.timestamp()
137
- yesterday = date.sub('day', 1)
138
- one_day = date.diff('day', yesterday)
139
- tomorrow = date.add('day', 1)
140
- two_day = tomorrow.diff('day', date) + one_day
141
- hour = date.hour()
142
- minute = date.minute()
143
- second = date.second()
144
- day_of_month = date.day_of_month()
145
- day_of_week = date.weekday()
146
- week_of_year = date.week_of_year()
147
- month = date.month()
148
- year = date.year()
149
- utc_date = date.UTC()
150
-
151
- @staticmethod
152
- def env_test(
153
- args: List[str],
154
- ) -> None:
155
- es = os.environ.get('TEST')
156
- ma = os.environ['TEST'] = es + 'test'
157
-
158
- @staticmethod
159
- async def env_test_async(
160
- args: List[str],
161
- ) -> None:
162
- es = os.environ.get('TEST')
163
- ma = os.environ['TEST'] = es + 'test'
164
-
165
- @staticmethod
166
- def file_test(
167
- args: List[str],
168
- ) -> None:
169
- if DaraFile.exists('/tmp/test'):
170
- file = DaraFile('/tmp/test')
171
- path = file.path()
172
- length = file.length() + 10
173
- create_time = file.create_time()
174
- modify_time = file.modify_time()
175
- time_long = modify_time.diff('minute', create_time)
176
- data = file.read(300)
177
- file.write(DaraBytes.from_('test', 'utf8'))
178
- rs = DaraFile.create_read_stream('/tmp/test')
179
- ws = DaraFile.create_write_stream('/tmp/test')
180
-
181
- @staticmethod
182
- async def file_test_async(
183
- args: List[str],
184
- ) -> None:
185
- if await DaraFile.exists_async('/tmp/test'):
186
- file = DaraFile('/tmp/test')
187
- path = file.path()
188
- length = await file.length_async() + 10
189
- create_time = await file.create_time_async()
190
- modify_time = await file.modify_time_async()
191
- time_long = modify_time.diff('minute', create_time)
192
- data = await file.read_async(300)
193
- await file.write_async(DaraBytes.from_('test', 'utf8'))
194
- rs = DaraFile.create_read_stream('/tmp/test')
195
- ws = DaraFile.create_write_stream('/tmp/test')
196
-
197
- @staticmethod
198
- def form_test(
199
- args: List[str],
200
- ) -> None:
201
- m = {
202
- 'key1': 'test1',
203
- 'key2': 'test2',
204
- 'key3': 3,
205
- 'key4': {
206
- 'key5': 123,
207
- 'key6': '321'
208
- }
209
- }
210
- form = DaraForm.to_form_string(m)
211
- form = form + '&key7=23233&key8=' + DaraForm.get_boundary()
212
- r = DaraForm.to_file_form(m, DaraForm.get_boundary())
213
-
214
- @staticmethod
215
- async def form_test_async(
216
- args: List[str],
217
- ) -> None:
218
- m = {
219
- 'key1': 'test1',
220
- 'key2': 'test2',
221
- 'key3': 3,
222
- 'key4': {
223
- 'key5': 123,
224
- 'key6': '321'
225
- }
226
- }
227
- form = DaraForm.to_form_string(m)
228
- form = form + '&key7=23233&key8=' + DaraForm.get_boundary()
229
- r = DaraForm.to_file_form(m, DaraForm.get_boundary())
230
-
231
- @staticmethod
232
- def json_test(
233
- args: List[str],
234
- ) -> None:
235
- m = {
236
- 'key1': 'test1',
237
- 'key2': 'test2',
238
- 'key3': 3,
239
- 'key4': {
240
- 'key5': 123,
241
- 'key6': '321'
242
- }
243
- }
244
- ms = DaraCore.to_json_string(m)
245
- ma = json.loads(ms)
246
- arr_str = '[1,2,3,4]'
247
- arr = json.loads(arr_str)
248
-
249
- @staticmethod
250
- async def json_test_async(
251
- args: List[str],
252
- ) -> None:
253
- m = {
254
- 'key1': 'test1',
255
- 'key2': 'test2',
256
- 'key3': 3,
257
- 'key4': {
258
- 'key5': 123,
259
- 'key6': '321'
260
- }
261
- }
262
- ms = DaraCore.to_json_string(m)
263
- ma = json.loads(ms)
264
- arr_str = '[1,2,3,4]'
265
- arr = json.loads(arr_str)
266
-
267
- @staticmethod
268
- def loger_test(
269
- args: List[str],
270
- ) -> None:
271
- logging.log(logging.NOTSET, 'test')
272
- logging.log(logging.INFO, 'test')
273
- logging.log(logging.WARNING, 'test')
274
- logging.log(logging.DEBUG, 'test')
275
- logging.log(logging.ERROR, 'test')
276
-
277
- @staticmethod
278
- async def loger_test_async(
279
- args: List[str],
280
- ) -> None:
281
- logging.log(logging.NOTSET, 'test')
282
- logging.log(logging.INFO, 'test')
283
- logging.log(logging.WARNING, 'test')
284
- logging.log(logging.DEBUG, 'test')
285
- logging.log(logging.ERROR, 'test')
286
-
287
- @staticmethod
288
- def map_test_case(
289
- args: List[str],
290
- ) -> None:
291
- map_test = {
292
- 'key1': 'value1',
293
- 'key2': 'value2',
294
- 'key3': 'value3'
295
- }
296
- length = len(map_test)
297
- num = length + 3
298
- keys = map_test.keys()
299
- all_key = ''
300
- for key in keys:
301
- all_key = all_key + key
302
- entries = map_test.items()
303
- new_key = ''
304
- new_value = ''
305
- for k, v in entries:
306
- new_key = new_key + k
307
- new_value = new_value + v
308
- json = json.dumps(map_test)
309
- map_test_2 = {
310
- 'key1': 'value4',
311
- 'key4': 'value5'
312
- }
313
- map_test_3 = map_test.update(map_test_2)
314
- if map_test_3.get('key1') == 'value4':
315
- return
316
-
317
- @staticmethod
318
- async def map_test_case_async(
319
- args: List[str],
320
- ) -> None:
321
- map_test = {
322
- 'key1': 'value1',
323
- 'key2': 'value2',
324
- 'key3': 'value3'
325
- }
326
- length = len(map_test)
327
- num = length + 3
328
- keys = map_test.keys()
329
- all_key = ''
330
- for key in keys:
331
- all_key = all_key + key
332
- entries = map_test.items()
333
- new_key = ''
334
- new_value = ''
335
- for k, v in entries:
336
- new_key = new_key + k
337
- new_value = new_value + v
338
- json = json.dumps(map_test)
339
- map_test_2 = {
340
- 'key1': 'value4',
341
- 'key4': 'value5'
342
- }
343
- map_test_3 = map_test.update(map_test_2)
344
- if map_test_3.get('key1') == 'value4':
345
- return
346
-
347
- @staticmethod
348
- def number_test(
349
- args: List[str],
350
- ) -> None:
351
- num = 3.2
352
- inum = int(num)
353
- lnum = int(num)
354
- fnum = float(num)
355
- dnum = float(num)
356
- inum = int(inum)
357
- lnum = int(inum)
358
- fnum = float(inum)
359
- dnum = float(inum)
360
- inum = int(lnum)
361
- lnum = int(lnum)
362
- fnum = float(lnum)
363
- dnum = float(lnum)
364
- inum = int(fnum)
365
- lnum = int(fnum)
366
- fnum = float(fnum)
367
- dnum = float(fnum)
368
- inum = int(dnum)
369
- lnum = int(dnum)
370
- fnum = float(dnum)
371
- dnum = float(dnum)
372
- lnum = inum
373
- inum = lnum
374
- random_num = random.random()
375
- inum = math.floor(inum)
376
- inum = round(inum)
377
-
378
- @staticmethod
379
- async def number_test_async(
380
- args: List[str],
381
- ) -> None:
382
- num = 3.2
383
- inum = int(num)
384
- lnum = int(num)
385
- fnum = float(num)
386
- dnum = float(num)
387
- inum = int(inum)
388
- lnum = int(inum)
389
- fnum = float(inum)
390
- dnum = float(inum)
391
- inum = int(lnum)
392
- lnum = int(lnum)
393
- fnum = float(lnum)
394
- dnum = float(lnum)
395
- inum = int(fnum)
396
- lnum = int(fnum)
397
- fnum = float(fnum)
398
- dnum = float(fnum)
399
- inum = int(dnum)
400
- lnum = int(dnum)
401
- fnum = float(dnum)
402
- dnum = float(dnum)
403
- lnum = inum
404
- inum = lnum
405
- random_num = random.random()
406
- inum = math.floor(inum)
407
- inum = round(inum)
408
-
409
- @staticmethod
410
- def stream_test(
411
- args: List[str],
412
- ) -> None:
413
- if DaraFile.exists('/tmp/test'):
414
- rs = DaraFile.create_read_stream('/tmp/test')
415
- ws = DaraFile.create_write_stream('/tmp/test')
416
- data = rs.read(30)
417
- ws.write(data)
418
-
419
- rs.seek(0)
420
-
421
- data = DaraStream.read_as_bytes(rs)
422
- obj = DaraStream.read_as_json(rs)
423
- json_str = DaraStream.read_as_string(rs)
424
-
425
- @staticmethod
426
- async def stream_test_async(
427
- args: List[str],
428
- ) -> None:
429
- if await DaraFile.exists_async('/tmp/test'):
430
- rs = DaraFile.create_read_stream('/tmp/test')
431
- ws = DaraFile.create_write_stream('/tmp/test')
432
- data = rs.read(30)
433
- ws.write(data)
434
-
435
- rs.seek(0)
436
-
437
- data = await DaraStream.read_as_bytes_async(rs)
438
- obj = await DaraStream.read_as_json_async(rs)
439
- json_str = await DaraStream.read_as_string_async(rs)
440
-
441
- @staticmethod
442
- def string_test(
443
- args: List[str],
444
- ) -> None:
445
- full_str = ','.join(args)
446
- args = full_str.split(',')
447
- if (len(full_str) > 0) and 'hangzhou' in full_str:
448
- new_str_1 = full_str.replace('hangzhou', 'beijing')
449
- if full_str.startswith('cn'):
450
- new_str_2 = full_str.replace('cn', 'zh', flags=re.IGNORECASE)
451
- if full_str.startswith('beijing'):
452
- new_str_3 = full_str.replace('beijing', 'chengdu', 1)
453
- start = full_str.find('beijing')
454
- end = start + 7
455
- region = full_str[start:end]
456
- lower_region = region.lower()
457
- upper_region = region.upper()
458
- if region == 'beijing':
459
- region = region + ' '
460
- region = region.strip()
461
- tb = full_str.encode('utf-8')
462
- em = 'xxx'
463
- if not em:
464
- return
465
- num = '32.0a'
466
- inum = int(num) + 3
467
- lnum = int(num)
468
- fnum = float(num) + 1
469
- dnum = float(num) + 1
470
-
471
- @staticmethod
472
- async def string_test_async(
473
- args: List[str],
474
- ) -> None:
475
- full_str = ','.join(args)
476
- args = full_str.split(',')
477
- if (len(full_str) > 0) and 'hangzhou' in full_str:
478
- new_str_1 = full_str.replace('hangzhou', 'beijing')
479
- if full_str.startswith('cn'):
480
- new_str_2 = full_str.replace('cn', 'zh', flags=re.IGNORECASE)
481
- if full_str.startswith('beijing'):
482
- new_str_3 = full_str.replace('beijing', 'chengdu', 1)
483
- start = full_str.find('beijing')
484
- end = start + 7
485
- region = full_str[start:end]
486
- lower_region = region.lower()
487
- upper_region = region.upper()
488
- if region == 'beijing':
489
- region = region + ' '
490
- region = region.strip()
491
- tb = full_str.encode('utf-8')
492
- em = 'xxx'
493
- if not em:
494
- return
495
- num = '32.0a'
496
- inum = int(num) + 3
497
- lnum = int(num)
498
- fnum = float(num) + 1
499
- dnum = float(num) + 1
500
-
501
- @staticmethod
502
- def url_test(
503
- args: List[str],
504
- ) -> None:
505
- url = DaraURL(args[0])
506
- path = url.path()
507
- pathname = url.pathname()
508
- protocol = url.protocol()
509
- hostname = url.hostname()
510
- port = url.port()
511
- host = url.host()
512
- hash = url.hash()
513
- search = url.search()
514
- href = url.href()
515
- auth = url.auth()
516
- url_2 = DaraURL.parse(args[1])
517
- path = url_2.path()
518
- new_url = DaraURL.url_encode(args[2])
519
- new_search = DaraURL.percent_encode(search)
520
- new_path = DaraURL.path_encode(pathname)
521
- all = 'test' + path + protocol + hostname + hash + search + href + auth + new_url + new_search + new_path
522
-
523
- @staticmethod
524
- async def url_test_async(
525
- args: List[str],
526
- ) -> None:
527
- url = DaraURL(args[0])
528
- path = url.path()
529
- pathname = url.pathname()
530
- protocol = url.protocol()
531
- hostname = url.hostname()
532
- port = url.port()
533
- host = url.host()
534
- hash = url.hash()
535
- search = url.search()
536
- href = url.href()
537
- auth = url.auth()
538
- url_2 = DaraURL.parse(args[1])
539
- path = url_2.path()
540
- new_url = DaraURL.url_encode(args[2])
541
- new_search = DaraURL.percent_encode(search)
542
- new_path = DaraURL.path_encode(pathname)
543
- all = 'test' + path + protocol + hostname + hash + search + href + auth + new_url + new_search + new_path
544
-
545
- @staticmethod
546
- def xml_test(
547
- args: List[str],
548
- ) -> None:
549
- m = {
550
- 'key1': 'test1',
551
- 'key2': 'test2',
552
- 'key3': 3,
553
- 'key4': {
554
- 'key5': 123,
555
- 'key6': '321'
556
- }
557
- }
558
- xml = DaraXML.to_xml(m)
559
- xml = xml + '<key7>132</key7>'
560
- resp_map = DaraXML.parse_xml(xml, None)
561
-
562
- @staticmethod
563
- async def xml_test_async(
564
- args: List[str],
565
- ) -> None:
566
- m = {
567
- 'key1': 'test1',
568
- 'key2': 'test2',
569
- 'key3': 3,
570
- 'key4': {
571
- 'key5': 123,
572
- 'key6': '321'
573
- }
574
- }
575
- xml = DaraXML.to_xml(m)
576
- xml = xml + '<key7>132</key7>'
577
- resp_map = DaraXML.parse_xml(xml, None)
578
-
579
- @staticmethod
580
- def return_any() -> Any:
581
- raise Exception('Un-implemented')
582
-
583
- @staticmethod
584
- def main(
585
- args: List[str],
586
- ) -> None:
587
- Client.array_test(args)
588
- Client.bytes_test(args)
589
- Client.date_test(args)
590
- Client.env_test(args)
591
- Client.file_test(args)
592
- Client.form_test(args)
593
- Client.loger_test(args)
594
- Client.map_test_case(args)
595
- Client.number_test(args)
596
- Client.stream_test(args)
597
- Client.string_test(args)
598
- Client.url_test(args)
599
- Client.xml_test(args)
600
- a = int(args[0]) + 10
601
- b = str(a) + args[1] + str(Client.return_any())
602
- c = DaraCore.to_number(b) + DaraCore.to_number(a) + DaraCore.to_number(Client.return_any())
603
- d = int(b) + int(a) + int(Client.return_any())
604
- e = int(b) + int(a) + int(Client.return_any())
605
- f = int(b) + int(a) + int(Client.return_any())
606
- g = int(b) + int(a) + int(Client.return_any())
607
- h = int(b) + int(a) + int(Client.return_any())
608
- i = int(b) + int(a) + int(Client.return_any())
609
- j = int(b) + int(a) + int(Client.return_any())
610
- k = int(b) + int(a) + int(Client.return_any())
611
- l = int(b) + int(a) + int(Client.return_any())
612
- m = int(b) + int(a) + int(Client.return_any())
613
- n = float(b) + float(a) + float(Client.return_any())
614
- o = float(b) + float(a) + float(Client.return_any())
615
- if bool(args[2]):
616
- data = bytes(Client.return_any())
617
- length = len(data)
618
- test = data
619
- maps = {
620
- 'key': 'value'
621
- }
622
- obj = maps
623
- ws = DaraStream.to_writable(obj)
624
- rs = DaraStream.to_readable(maps)
625
- data = rs.read(30)
626
- if not DaraCore.is_null(data):
627
- ws.write(data)
628
-
629
- DaraCore.sleep(a)
630
- default_val = args[0] or args[1]
631
- if default_val == b:
632
- return
633
-
634
- @staticmethod
635
- async def main_async(
636
- args: List[str],
637
- ) -> None:
638
- await Client.array_test_async(args)
639
- await Client.bytes_test_async(args)
640
- await Client.date_test_async(args)
641
- await Client.env_test_async(args)
642
- await Client.file_test_async(args)
643
- await Client.form_test_async(args)
644
- await Client.loger_test_async(args)
645
- await Client.map_test_case_async(args)
646
- await Client.number_test_async(args)
647
- await Client.stream_test_async(args)
648
- await Client.string_test_async(args)
649
- await Client.url_test_async(args)
650
- await Client.xml_test_async(args)
651
- a = int(args[0]) + 10
652
- b = str(a) + args[1] + str(Client.return_any())
653
- c = DaraCore.to_number(b) + DaraCore.to_number(a) + DaraCore.to_number(Client.return_any())
654
- d = int(b) + int(a) + int(Client.return_any())
655
- e = int(b) + int(a) + int(Client.return_any())
656
- f = int(b) + int(a) + int(Client.return_any())
657
- g = int(b) + int(a) + int(Client.return_any())
658
- h = int(b) + int(a) + int(Client.return_any())
659
- i = int(b) + int(a) + int(Client.return_any())
660
- j = int(b) + int(a) + int(Client.return_any())
661
- k = int(b) + int(a) + int(Client.return_any())
662
- l = int(b) + int(a) + int(Client.return_any())
663
- m = int(b) + int(a) + int(Client.return_any())
664
- n = float(b) + float(a) + float(Client.return_any())
665
- o = float(b) + float(a) + float(Client.return_any())
666
- if bool(args[2]):
667
- data = bytes(Client.return_any())
668
- length = len(data)
669
- test = data
670
- maps = {
671
- 'key': 'value'
672
- }
673
- obj = maps
674
- ws = DaraStream.to_writable(obj)
675
- rs = DaraStream.to_readable(maps)
676
- data = rs.read(30)
677
- if not DaraCore.is_null(data):
678
- ws.write(data)
679
-
680
- await DaraCore.sleep_async(a)
681
- default_val = args[0] or args[1]
682
- if default_val == b:
683
- return
684
-
685
-
686
- if __name__ == '__main__':
687
- Client.main(sys.argv[1:])