Fix CI issues: add workflow file and fix lint errors
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Python code generator."""
|
||||
{"""Python code generator."""
|
||||
|
||||
import json
|
||||
import base64
|
||||
@@ -40,18 +40,14 @@ def generate_python(parsed: ParsedCurl) -> str:
|
||||
lines.append("headers = " + _format_dict(headers))
|
||||
kwargs.append("headers=headers")
|
||||
|
||||
auth_tuple = None
|
||||
if parsed.auth:
|
||||
auth_username, auth_password = parsed.auth
|
||||
if ":" in parsed.auth[0]:
|
||||
try:
|
||||
encoded = base64.b64encode(f"{parsed.auth[0]}:{parsed.auth[1]}".encode()).decode()
|
||||
if "Authorization" not in headers:
|
||||
headers["Authorization"] = f"Basic {encoded}"
|
||||
except Exception:
|
||||
auth_tuple = parsed.auth
|
||||
else:
|
||||
auth_tuple = parsed.auth
|
||||
pass
|
||||
|
||||
if parsed.data:
|
||||
content_type = _detect_content_type(headers, parsed.data)
|
||||
@@ -92,4 +88,4 @@ def _format_dict(d: dict) -> str:
|
||||
items = []
|
||||
for k, v in d.items():
|
||||
items.append(f" {repr(k)}: {repr(v)}")
|
||||
return "{\n" + ",\n".join(items) + "\n}"
|
||||
return "{\n" + ",\n".join(items) + "\n}"
|
||||
Reference in New Issue
Block a user