http-content-parser 0.0.15__tar.gz → 0.0.17__tar.gz

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 (18) hide show
  1. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/PKG-INFO +1 -1
  2. http_content_parser-0.0.17/pyproject.toml +19 -0
  3. http_content_parser-0.0.17/src/http_content_parser/__init__.py +1 -0
  4. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/generate_api_file.py +16 -3
  5. http_content_parser-0.0.17/tests/test_curl.py +20 -0
  6. http_content_parser-0.0.15/pyproject.toml +0 -18
  7. http_content_parser-0.0.15/src/http_content_parser/__init__.py +0 -0
  8. http_content_parser-0.0.15/tests/test_curl.py +0 -37
  9. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/.gitignore +0 -0
  10. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/LICENSE +0 -0
  11. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/README.md +0 -0
  12. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/requirements.txt +0 -0
  13. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/curl_parser.py +0 -0
  14. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/openapi_parser.py +0 -0
  15. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/param_util.py +0 -0
  16. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/postman_parser.py +0 -0
  17. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/req_data.py +0 -0
  18. {http_content_parser-0.0.15 → http_content_parser-0.0.17}/src/http_content_parser/swagger2_parser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: http_content_parser
3
- Version: 0.0.15
3
+ Version: 0.0.17
4
4
  Summary: parse http's payload and response
5
5
  Author-email: max su <suleiabc@gmail.com>
6
6
  License-File: LICENSE
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "http_content_parser"
7
+ version = "0.0.17"
8
+ authors = [{ name = "max su", email = "suleiabc@gmail.com" }]
9
+ description = "parse http's payload and response"
10
+ readme = "README.md"
11
+ requires-python = ">=3.8"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+
18
+ [tool.pytest.ini_options]
19
+ pythonpath = [".", "src"]
@@ -1,4 +1,5 @@
1
1
  # -*- coding: UTF-8 -*-
2
+ import copy
2
3
  import json
3
4
  import re
4
5
 
@@ -40,11 +41,23 @@ class GenerateApiFile:
40
41
  payload_list = self.convert_curl_data_to_model(
41
42
  curl_file_path=curl_file, curl_filter=curl_filter
42
43
  )
44
+ # handle duplicate key
45
+ new_payload_list = self.handle_duplicate_yaml_key(payload_list)
43
46
  # write to yaml
44
- for payload in payload_list:
47
+ for payload in new_payload_list:
45
48
  self.write_api_content_to_yaml(yaml_file, payload)
46
- # remove duplicate key
47
- # self.remove_duplicate_key_for_yaml(yaml_file)
49
+
50
+ def handle_duplicate_yaml_key(self, payload_list: list[ReqData]) -> list[ReqData]:
51
+ key_filter = {}
52
+ new_payload_list = copy.deepcopy(payload_list)
53
+ for payload, p_copy in zip(payload_list, new_payload_list):
54
+ k = payload.temp_api_label
55
+ if k in key_filter.keys():
56
+ p_copy.temp_api_label = k + "_" + str(key_filter[k])
57
+ key_filter[k] += 1
58
+ else:
59
+ key_filter[k] = 1
60
+ return new_payload_list
48
61
 
49
62
  def convert_curl_data_to_model(
50
63
  self, curl_file_path, curl_filter=None
@@ -0,0 +1,20 @@
1
+ import json
2
+
3
+ from http_content_parser.generate_api_file import GenerateApiFile
4
+
5
+
6
+ def test_curl():
7
+ gaf = GenerateApiFile()
8
+ # with open("./postman.json", "r") as f:
9
+ # json_dict = json.load(f)
10
+ # gaf.produce_api_yaml_for_postman(json_dict, "./test.yaml")
11
+ curl_file = ""
12
+ res = gaf.produce_api_yaml_for_curl(curl_file=curl_file, yaml_file="api.yaml")
13
+
14
+
15
+ def test_for():
16
+ data = {"name": "John", "age": 30, "city": "New York"}
17
+ temp = '{ "job_id":{{job_id}}, "product_id": 4, "local_user_id": 0}'
18
+ temp = json.dumps(data)
19
+ temp = json.loads(temp)
20
+ print(temp)
@@ -1,18 +0,0 @@
1
- [build-system]
2
- requires = ["hatchling"]
3
- build-backend = "hatchling.build"
4
-
5
- [project]
6
- name = "http_content_parser"
7
- version = "0.0.15"
8
- authors = [
9
- { name="max su", email="suleiabc@gmail.com" },
10
- ]
11
- description = "parse http's payload and response"
12
- readme = "README.md"
13
- requires-python = ">=3.8"
14
- classifiers = [
15
- "Programming Language :: Python :: 3",
16
- "License :: OSI Approved :: MIT License",
17
- "Operating System :: OS Independent",
18
- ]
@@ -1,37 +0,0 @@
1
- import json
2
- import sys
3
- from os.path import abspath, join, dirname
4
-
5
- sys.path.insert(0, join(abspath(dirname(__file__)), "src"))
6
- print(sys.path)
7
- from http_content_parser.generate_api_file import GenerateApiFile
8
-
9
-
10
- class TestCases:
11
- def test_curl(self):
12
- gaf = GenerateApiFile()
13
- # with open("./postman.json", "r") as f:
14
- # json_dict = json.load(f)
15
- # gaf.produce_api_yaml_for_postman(json_dict, "./test.yaml")
16
- curl_file = '/Users/lei.susl/Desktop/test1/iac-dispatcher/tmp2'
17
- res = gaf.convert_curl_data_to_model(curl_file_path=curl_file)
18
- for r in res:
19
- print('body is: \n')
20
- print(r.body)
21
- print('header is: \n')
22
- print(r.header)
23
-
24
-
25
- def test_for(self):
26
- # c = 1
27
- # for i in range(6):
28
- # if i > c:
29
- # i += 1
30
- # while i < 6:
31
- # i += 1
32
- # print(str(i))
33
- data = {"name": "John", "age": 30, "city": "New York"}
34
- temp = '{ "job_id":{{job_id}}, "product_id": 4, "local_user_id": 0}'
35
- temp = json.dumps(data)
36
- temp = json.loads(temp)
37
- print(temp)