json2xml 4.1.0__tar.gz → 5.0.0__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.
- {json2xml-4.1.0 → json2xml-5.0.0}/PKG-INFO +1 -1
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml/__init__.py +1 -1
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml/dicttoxml.py +2 -2
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml/json2xml.py +2 -2
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml/utils.py +3 -3
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/PKG-INFO +1 -1
- {json2xml-4.1.0 → json2xml-5.0.0}/tests/test_json2xml.py +0 -9
- {json2xml-4.1.0 → json2xml-5.0.0}/AUTHORS.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/CONTRIBUTING.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/HISTORY.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/LICENSE +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/MANIFEST.in +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/README.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/Makefile +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/authors.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/conf.py +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/contributing.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/history.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/index.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/installation.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/json2xml.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/make.bat +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/modules.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/readme.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/docs/usage.rst +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/SOURCES.txt +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/dependency_links.txt +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/not-zip-safe +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/requires.txt +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/json2xml.egg-info/top_level.txt +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/pyproject.toml +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/requirements.in +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/setup.cfg +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/setup.py +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/tests/__init__.py +0 -0
- {json2xml-4.1.0 → json2xml-5.0.0}/tests/test_dict2xml.py +0 -0
|
@@ -14,7 +14,7 @@ class Json2xml:
|
|
|
14
14
|
"""
|
|
15
15
|
def __init__(
|
|
16
16
|
self,
|
|
17
|
-
data:
|
|
17
|
+
data: dict[str, Any] | None = None,
|
|
18
18
|
wrapper: str = "all",
|
|
19
19
|
root: bool = True,
|
|
20
20
|
pretty: bool = True,
|
|
@@ -28,7 +28,7 @@ class Json2xml:
|
|
|
28
28
|
self.root = root
|
|
29
29
|
self.item_wrap = item_wrap
|
|
30
30
|
|
|
31
|
-
def to_xml(self) ->
|
|
31
|
+
def to_xml(self) -> Any | None:
|
|
32
32
|
"""
|
|
33
33
|
Convert to xml using dicttoxml.dicttoxml and then pretty print it.
|
|
34
34
|
"""
|
|
@@ -25,7 +25,7 @@ class StringReadError(Exception):
|
|
|
25
25
|
pass
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def readfromjson(filename: str) ->
|
|
28
|
+
def readfromjson(filename: str) -> dict[str, str]:
|
|
29
29
|
"""Reads a JSON file and returns a dictionary."""
|
|
30
30
|
try:
|
|
31
31
|
with open(filename, encoding="utf-8") as jsondata:
|
|
@@ -36,7 +36,7 @@ def readfromjson(filename: str) -> Dict[str, str]:
|
|
|
36
36
|
raise JSONReadError("Invalid JSON File")
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def readfromurl(url: str, params:
|
|
39
|
+
def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str]:
|
|
40
40
|
"""Loads JSON data from a URL and returns a dictionary."""
|
|
41
41
|
http = urllib3.PoolManager()
|
|
42
42
|
response = http.request("GET", url, fields=params)
|
|
@@ -45,7 +45,7 @@ def readfromurl(url: str, params: Optional[Dict[str, str]] = None) -> Dict[str,
|
|
|
45
45
|
raise URLReadError("URL is not returning correct response")
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def readfromstring(jsondata: str) ->
|
|
48
|
+
def readfromstring(jsondata: str) -> dict[str, str]:
|
|
49
49
|
"""Loads JSON data from a string and returns a dictionary."""
|
|
50
50
|
if not isinstance(jsondata, str):
|
|
51
51
|
raise StringReadError("Input is not a proper JSON string")
|
|
@@ -50,15 +50,6 @@ class TestJson2xml:
|
|
|
50
50
|
readfromjson("examples/wrongjson.json")
|
|
51
51
|
assert pytest_wrapped_e.type == JSONReadError
|
|
52
52
|
|
|
53
|
-
def test_read_from_url(self):
|
|
54
|
-
data = readfromurl("https://api.publicapis.org/entries")
|
|
55
|
-
assert isinstance(data, dict)
|
|
56
|
-
|
|
57
|
-
def test_read_from_wrong_url(self):
|
|
58
|
-
with pytest.raises(URLReadError) as pytest_wrapped_e:
|
|
59
|
-
readfromurl("https://api.publicapis.org/entriesi")
|
|
60
|
-
assert pytest_wrapped_e.type == URLReadError
|
|
61
|
-
|
|
62
53
|
def test_read_from_jsonstring(self):
|
|
63
54
|
data = readfromstring(
|
|
64
55
|
'{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|