xmlpydict 0.0.11__tar.gz → 0.0.12__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.
- {xmlpydict-0.0.11/xmlpydict.egg-info → xmlpydict-0.0.12}/PKG-INFO +2 -2
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/pyproject.toml +2 -2
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/xmlpydict/__init__.py +31 -1
- {xmlpydict-0.0.11 → xmlpydict-0.0.12/xmlpydict.egg-info}/PKG-INFO +2 -2
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/LICENSE +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/MANIFEST.in +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/README.md +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/setup.cfg +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/setup.py +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/src/xmlparse.cpp +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/tests/test_parse.py +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/xmlpydict.egg-info/SOURCES.txt +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/xmlpydict.egg-info/dependency_links.txt +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/xmlpydict.egg-info/requires.txt +0 -0
- {xmlpydict-0.0.11 → xmlpydict-0.0.12}/xmlpydict.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmlpydict
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
4
4
|
Summary: xml to dictionary tool for python
|
|
5
5
|
Author-email: Matthew Taylor <matthew.taylor.andre@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/MatthewAndreTaylor/xml-to-pydict
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
19
|
Classifier: Topic :: Text Processing :: Markup :: XML
|
|
20
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Provides-Extra: tests
|
|
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "xmlpydict"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.12"
|
|
8
8
|
description="xml to dictionary tool for python"
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Matthew Taylor", email = "matthew.taylor.andre@gmail.com"},
|
|
11
11
|
]
|
|
12
12
|
urls = {Homepage = "https://github.com/MatthewAndreTaylor/xml-to-pydict"}
|
|
13
|
-
requires-python = ">=3.
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
14
|
keywords = [ "xml", "dictionary" ]
|
|
15
15
|
classifiers = [
|
|
16
16
|
"Development Status :: 3 - Alpha",
|
|
@@ -40,6 +40,36 @@ def parse_file(file_path, attr_prefix: str = "@", cdata_key: str = "#text") -> d
|
|
|
40
40
|
parser.CharacterDataHandler = handler.characters
|
|
41
41
|
parser.StartElementHandler = handler.startElement
|
|
42
42
|
parser.EndElementHandler = handler.endElement
|
|
43
|
-
with open(file_path, "
|
|
43
|
+
with open(file_path, "rb") as f:
|
|
44
44
|
parser.ParseFile(f)
|
|
45
45
|
return handler.item
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def iter_xml_documents(file_path, chunk_size=64 * 1024):
|
|
50
|
+
start_token = b"<?xml"
|
|
51
|
+
buffer = b""
|
|
52
|
+
with open(file_path, "rb") as f:
|
|
53
|
+
while True:
|
|
54
|
+
chunk = f.read(chunk_size)
|
|
55
|
+
if not chunk:
|
|
56
|
+
if buffer.strip():
|
|
57
|
+
yield buffer
|
|
58
|
+
break
|
|
59
|
+
buffer += chunk
|
|
60
|
+
while True:
|
|
61
|
+
start_index = buffer.find(start_token, 1)
|
|
62
|
+
if start_index == -1:
|
|
63
|
+
break
|
|
64
|
+
yield buffer[:start_index]
|
|
65
|
+
buffer = buffer[start_index:]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def parse_xml_collections(file_path, attr_prefix: str = "@", cdata_key: str = "#text"):
|
|
70
|
+
for xml_content in iter_xml_documents(file_path):
|
|
71
|
+
yield parse(
|
|
72
|
+
xml_content.decode("utf-8"),
|
|
73
|
+
attr_prefix=attr_prefix,
|
|
74
|
+
cdata_key=cdata_key
|
|
75
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmlpydict
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
4
4
|
Summary: xml to dictionary tool for python
|
|
5
5
|
Author-email: Matthew Taylor <matthew.taylor.andre@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/MatthewAndreTaylor/xml-to-pydict
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
19
|
Classifier: Topic :: Text Processing :: Markup :: XML
|
|
20
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Provides-Extra: tests
|
|
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
|