Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: django CMS linters.yml
name: json2xml linters.yml

on: [push, pull_request]

Expand Down
13 changes: 7 additions & 6 deletions json2xml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Utils methods to convert XML data to dict from various sources"""
import json

import requests
import urllib3


class JSONReadError(Exception):
Expand Down Expand Up @@ -43,11 +43,12 @@ def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str
"""
Loads json from an URL over the internets
"""
# TODO: See if we can remove requests too from the deps too. Then, we will become
# zero deps. refernce link here: https://bit.ly/3gzICjU
response = requests.get(url, params=params)
if response.status_code == 200:
data = response.json()
# we need a PoolManager for connection pooling with urllib3. Also, params
# needs to be encoded too
http = urllib3.PoolManager()
response = http.request("GET", url, fields=params)
if response.status == 200:
data = json.loads(response.data.decode('utf-8'))
return data
raise URLReadError("URL is not returning correct response")

Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests>=2.20.0
defusedxml==0.7.1
urllib3==1.26.13

10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile
#
defusedxml==0.7.1
# via -r requirements.in
urllib3==1.26.13
# via -r requirements.in
Loading