http-content-parser 0.0.12__tar.gz → 0.0.14__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: http_content_parser
3
- Version: 0.0.12
3
+ Version: 0.0.14
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,16 @@ Description-Content-Type: text/markdown
13
13
  # HttpParser Package
14
14
 
15
15
  This is a http content parser package.
16
+
17
+ ## build package
18
+
19
+ ```bash
20
+ python3 -m build
21
+ ```
22
+
23
+ ## upload to pypi
24
+
25
+ ```bash
26
+ rm -f dist/*
27
+ python3 -m twine upload dist/*
28
+ ```
@@ -0,0 +1,16 @@
1
+ # HttpParser Package
2
+
3
+ This is a http content parser package.
4
+
5
+ ## build package
6
+
7
+ ```bash
8
+ python3 -m build
9
+ ```
10
+
11
+ ## upload to pypi
12
+
13
+ ```bash
14
+ rm -f dist/*
15
+ python3 -m twine upload dist/*
16
+ ```
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "http_content_parser"
7
- version = "0.0.12"
7
+ version = "0.0.14"
8
8
  authors = [
9
9
  { name="max su", email="suleiabc@gmail.com" },
10
10
  ]
@@ -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
 
@@ -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
- # TODO 空格区分有用和无用,目前cookie的value中会有包含空格的情况, 不删除
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,12 +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", "")
116
- )
109
+ body = re.sub( r"\n\s*", "", curl_data.replace(" \\\n", ""))
110
+ req_data["body"] = body[:-1]
117
111
 
118
112
  if not req_data.get("method"):
119
113
  req_data["method"] = "post"
@@ -13,9 +13,13 @@ class TestCases:
13
13
  # with open("./postman.json", "r") as f:
14
14
  # json_dict = json.load(f)
15
15
  # gaf.produce_api_yaml_for_postman(json_dict, "./test.yaml")
16
- curl_file = '/Users/lei.susl/Desktop/test1/iac.txt'
16
+ curl_file = '/Users/lei.susl/Desktop/test1/iac-dispatcher/tmp2'
17
17
  res = gaf.convert_curl_data_to_model(curl_file_path=curl_file)
18
- print(res)
18
+ for r in res:
19
+ print('body is: \n')
20
+ print(r.body)
21
+ print('header is: \n')
22
+ print(r.header)
19
23
 
20
24
 
21
25
  def test_for(self):
@@ -1,3 +0,0 @@
1
- # HttpParser Package
2
-
3
- This is a http content parser package.