maxml 1.0.0__py3-none-any.whl → 1.0.2__py3-none-any.whl
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.
- maxml/element/__init__.py +38 -6
- maxml/version.txt +1 -1
- {maxml-1.0.0.dist-info → maxml-1.0.2.dist-info}/METADATA +4 -3
- maxml-1.0.2.dist-info/RECORD +10 -0
- maxml-1.0.0.dist-info/RECORD +0 -10
- {maxml-1.0.0.dist-info → maxml-1.0.2.dist-info}/WHEEL +0 -0
- {maxml-1.0.0.dist-info → maxml-1.0.2.dist-info}/top_level.txt +0 -0
- {maxml-1.0.0.dist-info → maxml-1.0.2.dist-info}/zip-safe +0 -0
maxml/element/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from maxml.namespace import Namespace
|
|
4
4
|
from maxml.logging import logger
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from classicist import hybridmethod
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
logger = logger.getChild(__name__)
|
|
@@ -71,7 +71,7 @@ class Element(object):
|
|
|
71
71
|
for namespace in self._namespaces:
|
|
72
72
|
if namespace.prefix == prefix:
|
|
73
73
|
if namespace.uri == uri:
|
|
74
|
-
logger.
|
|
74
|
+
logger.info(
|
|
75
75
|
" >>> The '%s' namespace has already been registered..."
|
|
76
76
|
% (prefix)
|
|
77
77
|
)
|
|
@@ -139,14 +139,40 @@ class Element(object):
|
|
|
139
139
|
|
|
140
140
|
self._namespaces: set[Namespace] = set()
|
|
141
141
|
|
|
142
|
+
for key in list(attributes.keys()):
|
|
143
|
+
if key.startswith("xmlns:") and (xmlns := key.replace("xmlns:", "")):
|
|
144
|
+
for namespace in self.__class__._namespaces:
|
|
145
|
+
if namespace.prefix == xmlns:
|
|
146
|
+
break
|
|
147
|
+
else:
|
|
148
|
+
namespace = Namespace(prefix=xmlns, uri=attributes[key])
|
|
149
|
+
|
|
150
|
+
self.__class__._namespaces.add(namespace)
|
|
151
|
+
|
|
152
|
+
self._namespaces.add(namespace)
|
|
153
|
+
|
|
154
|
+
del attributes[key]
|
|
155
|
+
|
|
142
156
|
if namespace is None:
|
|
143
157
|
for namespace in self.__class__._namespaces:
|
|
144
158
|
if namespace.prefix == prefix:
|
|
145
159
|
break
|
|
146
160
|
else:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
for key in list(attributes.keys()):
|
|
162
|
+
if key.startswith("xmlns:") and key.endswith(prefix):
|
|
163
|
+
namespace = Namespace(prefix=prefix, uri=attributes[key])
|
|
164
|
+
|
|
165
|
+
self.__class__._namespaces.add(namespace)
|
|
166
|
+
|
|
167
|
+
self._namespaces.add(namespace)
|
|
168
|
+
|
|
169
|
+
del attributes[key]
|
|
170
|
+
|
|
171
|
+
break
|
|
172
|
+
else:
|
|
173
|
+
raise ValueError(
|
|
174
|
+
f"No namespace has been registered for the '{prefix}' prefix associated with the '{name}' element!"
|
|
175
|
+
)
|
|
150
176
|
|
|
151
177
|
self._namespaces.add(namespace.copy().promote())
|
|
152
178
|
elif isinstance(uri := namespace, str):
|
|
@@ -350,7 +376,10 @@ class Element(object):
|
|
|
350
376
|
"The 'value' argument must have a value that can be cast to a string!"
|
|
351
377
|
)
|
|
352
378
|
|
|
353
|
-
|
|
379
|
+
if name.startswith("xmlns:"):
|
|
380
|
+
self.register_namespace(prefix=name.replace("xmlns:", ""), uri=value)
|
|
381
|
+
else:
|
|
382
|
+
self._attributes[name] = value
|
|
354
383
|
|
|
355
384
|
return self
|
|
356
385
|
|
|
@@ -588,6 +617,9 @@ class Element(object):
|
|
|
588
617
|
# Add any attributes
|
|
589
618
|
count = len(element.attributes)
|
|
590
619
|
for index, (key, value) in enumerate(element.attributes.items(), start=1):
|
|
620
|
+
if key.startswith("xmlns:"):
|
|
621
|
+
continue
|
|
622
|
+
|
|
591
623
|
if pretty and count > 1 and index >= 1 and index <= count:
|
|
592
624
|
string += f"\n{indent * (depth + 2)}"
|
|
593
625
|
newline = True
|
maxml/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maxml
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: A streamlined pure Python XML serializer.
|
|
5
5
|
Author: Daniel Sissman
|
|
6
6
|
License-Expression: MIT
|
|
@@ -18,7 +18,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
|
-
Requires-Dist:
|
|
21
|
+
Requires-Dist: classicist==1.0.*
|
|
22
|
+
Requires-Dist: enumerific==1.0.*
|
|
22
23
|
Provides-Extra: development
|
|
23
24
|
Requires-Dist: black==24.10.*; extra == "development"
|
|
24
25
|
Requires-Dist: pytest==8.3.*; extra == "development"
|
|
@@ -48,7 +49,7 @@ using `pip` via the `pip install` command by entering the following into your sh
|
|
|
48
49
|
|
|
49
50
|
### Example Usage
|
|
50
51
|
|
|
51
|
-
To use the MaXML library, import the library
|
|
52
|
+
To use the MaXML library, import the library and begin creating your XML document:
|
|
52
53
|
|
|
53
54
|
```python
|
|
54
55
|
import maxml
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
maxml/__init__.py,sha256=QuUB-oFrPKRZ4XzPuk4Mt8r35EMx652PALyAeWvQXIo,72
|
|
2
|
+
maxml/version.txt,sha256=v-wuNFg62n5q8stzmT-3Wj9xR6bJQ-X_X1xClPxXe5A,5
|
|
3
|
+
maxml/element/__init__.py,sha256=8N6ePtw7nOX6VVQ0eG5mmDJkBXo8S1qwVF3k9X2OmLo,23843
|
|
4
|
+
maxml/logging/__init__.py,sha256=AMpvZEQH9GIBe8609sMwb2T64rovpkRRCc9rs2kHy8g,52
|
|
5
|
+
maxml/namespace/__init__.py,sha256=iZqHWuGi09KtMTr7wHiyTQLXB2TFljUir8wZGLi2b60,3882
|
|
6
|
+
maxml-1.0.2.dist-info/METADATA,sha256=J9F0r0aKB7prWv2tALoHhPRtFYCUXm096UOdoRQW5Fc,16193
|
|
7
|
+
maxml-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
maxml-1.0.2.dist-info/top_level.txt,sha256=ZFK3SmCc04Dzhl9QkO_hVBAEiHwCNrwn8X_PINWE9C4,6
|
|
9
|
+
maxml-1.0.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
+
maxml-1.0.2.dist-info/RECORD,,
|
maxml-1.0.0.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
maxml/__init__.py,sha256=QuUB-oFrPKRZ4XzPuk4Mt8r35EMx652PALyAeWvQXIo,72
|
|
2
|
-
maxml/version.txt,sha256=klIfw8vZZL3J9YSpkbif3apXVO0cyW1tQkRTOGacEwU,5
|
|
3
|
-
maxml/element/__init__.py,sha256=jCrnThqnN6hACfmbsFZcY8MMV4czBCmoYOOpVpRjzDQ,22673
|
|
4
|
-
maxml/logging/__init__.py,sha256=AMpvZEQH9GIBe8609sMwb2T64rovpkRRCc9rs2kHy8g,52
|
|
5
|
-
maxml/namespace/__init__.py,sha256=iZqHWuGi09KtMTr7wHiyTQLXB2TFljUir8wZGLi2b60,3882
|
|
6
|
-
maxml-1.0.0.dist-info/METADATA,sha256=LW_yxkgZyiuT3fOmtnkiWKoEra0hHpvY7M-igpXXt6g,16164
|
|
7
|
-
maxml-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
maxml-1.0.0.dist-info/top_level.txt,sha256=ZFK3SmCc04Dzhl9QkO_hVBAEiHwCNrwn8X_PINWE9C4,6
|
|
9
|
-
maxml-1.0.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
-
maxml-1.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|