http-content-parser 0.0.11__tar.gz → 0.0.13__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.
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/PKG-INFO +13 -1
- http_content_parser-0.0.13/README.md +15 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/pyproject.toml +1 -1
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/curl_parser.py +5 -10
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/tests/test_curl.py +12 -4
- http_content_parser-0.0.11/README.md +0 -3
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/.gitignore +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/LICENSE +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/requirements.txt +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/__init__.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/generate_api_file.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/openapi_parser.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/param_util.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/postman_parser.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/req_data.py +0 -0
- {http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/swagger2_parser.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: http_content_parser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.13
|
|
4
4
|
Summary: parse http's payload and response
|
|
5
5
|
Author-email: max su <suleiabc@gmail.com>
|
|
6
6
|
License-File: LICENSE
|
|
@@ -13,3 +13,15 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
# HttpParser Package
|
|
14
14
|
|
|
15
15
|
This is a http content parser package.
|
|
16
|
+
|
|
17
|
+
## package
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## upload to pypi
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python3 -m twine upload dist/*
|
|
27
|
+
```
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/curl_parser.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
|
2
|
+
import re
|
|
2
3
|
from urllib.parse import urlparse, parse_qs
|
|
3
4
|
|
|
4
5
|
|
|
@@ -26,7 +27,7 @@ class CurlParser(object):
|
|
|
26
27
|
new_i = -1
|
|
27
28
|
for i in range(s, e):
|
|
28
29
|
new_line = lines[i]
|
|
29
|
-
if "--data " in lines[i]:
|
|
30
|
+
if "--data " in lines[i] or "--data-raw " in lines[i]:
|
|
30
31
|
# 判断请求的body是否完整,根据''单引号是否是两个
|
|
31
32
|
char_count = lines[i].count("'")
|
|
32
33
|
if char_count == 1:
|
|
@@ -94,10 +95,7 @@ class CurlParser(object):
|
|
|
94
95
|
line_i_list = lines_i_str.split(" '")
|
|
95
96
|
subs = str(line_i_list[1]).split(":")
|
|
96
97
|
if len(subs) > 1:
|
|
97
|
-
|
|
98
|
-
header[subs[0]] = (
|
|
99
|
-
subs[1].replace("'", "").replace("\\\n", "").replace(" ", "")
|
|
100
|
-
)
|
|
98
|
+
header[subs[0]] = subs[1][1:].replace("'", "").replace(" \\\n", "")
|
|
101
99
|
else:
|
|
102
100
|
header[subs[0]] = ""
|
|
103
101
|
elif "--data-raw" in lines_i_str or "--data" in lines_i_str:
|
|
@@ -108,11 +106,8 @@ class CurlParser(object):
|
|
|
108
106
|
curl_data = line_i_list[1]
|
|
109
107
|
else:
|
|
110
108
|
curl_data = line_i_list[0]
|
|
111
|
-
req_data["body"] = (
|
|
112
|
-
curl_data.replace("
|
|
113
|
-
.replace(" ", "")
|
|
114
|
-
.replace("\\\n", "")
|
|
115
|
-
.replace("\n", "")
|
|
109
|
+
req_data["body"] = re.sub(
|
|
110
|
+
r"\n\s*", "", curl_data.replace(" \\\n", "")[:-1]
|
|
116
111
|
)
|
|
117
112
|
|
|
118
113
|
if not req_data.get("method"):
|
|
@@ -2,7 +2,7 @@ import json
|
|
|
2
2
|
import sys
|
|
3
3
|
from os.path import abspath, join, dirname
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
sys.path.insert(0, join(abspath(dirname(__file__)), "src"))
|
|
6
6
|
print(sys.path)
|
|
7
7
|
from http_content_parser.generate_api_file import GenerateApiFile
|
|
8
8
|
|
|
@@ -10,9 +10,17 @@ from http_content_parser.generate_api_file import GenerateApiFile
|
|
|
10
10
|
class TestCases:
|
|
11
11
|
def test_curl(self):
|
|
12
12
|
gaf = GenerateApiFile()
|
|
13
|
-
with open("./postman.json", "r") as f:
|
|
14
|
-
|
|
15
|
-
gaf.produce_api_yaml_for_postman(json_dict, "./test.yaml")
|
|
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/tmp'
|
|
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
|
+
|
|
16
24
|
|
|
17
25
|
def test_for(self):
|
|
18
26
|
# c = 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/openapi_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/param_util.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/postman_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/req_data.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.11 → http_content_parser-0.0.13}/src/http_content_parser/swagger2_parser.py
RENAMED
|
File without changes
|