maxml 1.0.3__py3-none-any.whl → 1.0.5__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 +9 -6
- maxml/namespace/__init__.py +7 -2
- maxml/version.txt +1 -1
- {maxml-1.0.3.dist-info → maxml-1.0.5.dist-info}/METADATA +20 -7
- maxml-1.0.5.dist-info/RECORD +12 -0
- {maxml-1.0.3.dist-info → maxml-1.0.5.dist-info}/WHEEL +1 -1
- maxml-1.0.3.dist-info/RECORD +0 -12
- {maxml-1.0.3.dist-info → maxml-1.0.5.dist-info}/top_level.txt +0 -0
- {maxml-1.0.3.dist-info → maxml-1.0.5.dist-info}/zip-safe +0 -0
maxml/element/__init__.py
CHANGED
|
@@ -28,7 +28,7 @@ class Element(object):
|
|
|
28
28
|
_mixed: bool = False
|
|
29
29
|
|
|
30
30
|
@hybridmethod
|
|
31
|
-
def register_namespace(self, prefix: str, uri: str):
|
|
31
|
+
def register_namespace(self, prefix: str, uri: str, promoted: bool = False):
|
|
32
32
|
"""Supports registering namespaces globally for the module or per instance
|
|
33
33
|
depending on whether the method is called on the class directly or whether it is
|
|
34
34
|
called on a specific instance of the class.
|
|
@@ -74,6 +74,9 @@ class Element(object):
|
|
|
74
74
|
if not isinstance(uri, str):
|
|
75
75
|
raise TypeError("The 'uri' argument must have a string value!")
|
|
76
76
|
|
|
77
|
+
if not isinstance(promoted, bool):
|
|
78
|
+
raise TypeError("The 'promoted' argument must have a boolean value!")
|
|
79
|
+
|
|
77
80
|
for namespace in self._namespaces:
|
|
78
81
|
if namespace.prefix == prefix:
|
|
79
82
|
if namespace.uri == uri:
|
|
@@ -88,7 +91,7 @@ class Element(object):
|
|
|
88
91
|
% (prefix, uri, namespace.uri)
|
|
89
92
|
)
|
|
90
93
|
else:
|
|
91
|
-
if namespace := Namespace(prefix=prefix, uri=uri):
|
|
94
|
+
if namespace := Namespace(prefix=prefix, uri=uri, promoted=promoted):
|
|
92
95
|
self._namespaces.add(namespace)
|
|
93
96
|
|
|
94
97
|
def __init__(
|
|
@@ -119,7 +122,7 @@ class Element(object):
|
|
|
119
122
|
prefix: str = None
|
|
120
123
|
|
|
121
124
|
if ":" in name:
|
|
122
|
-
|
|
125
|
+
prefix, basename = name.split(":", maxsplit=1)
|
|
123
126
|
|
|
124
127
|
self._prefix: str = prefix
|
|
125
128
|
|
|
@@ -186,7 +189,7 @@ class Element(object):
|
|
|
186
189
|
if namespace.uri == uri:
|
|
187
190
|
break
|
|
188
191
|
else:
|
|
189
|
-
namespace = Namespace(prefix=prefix, uri=uri)
|
|
192
|
+
namespace = Namespace(prefix=prefix, uri=uri, promoted=False)
|
|
190
193
|
|
|
191
194
|
self.__class__._namespaces.add(namespace)
|
|
192
195
|
|
|
@@ -662,7 +665,7 @@ class Element(object):
|
|
|
662
665
|
# Add any promoted namespaces (those which should proceed any attributes)
|
|
663
666
|
count = len(element.namespaced)
|
|
664
667
|
for index, namespace in enumerate(element.namespaced, start=1):
|
|
665
|
-
if
|
|
668
|
+
if namespace.promoted is False:
|
|
666
669
|
continue
|
|
667
670
|
|
|
668
671
|
if pretty and count > 1 and (newline or (index > 1 and index <= count)):
|
|
@@ -691,7 +694,7 @@ class Element(object):
|
|
|
691
694
|
newline = True
|
|
692
695
|
|
|
693
696
|
for index, namespace in enumerate(element.namespaced, start=1):
|
|
694
|
-
if namespace.promoted:
|
|
697
|
+
if namespace.promoted is True:
|
|
695
698
|
continue
|
|
696
699
|
|
|
697
700
|
if pretty and count > 1 and (newline or (index > 1 and index <= count)):
|
maxml/namespace/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@ class Namespace(object):
|
|
|
14
14
|
_uri: str = None
|
|
15
15
|
_promoted: bool = False
|
|
16
16
|
|
|
17
|
-
def __init__(self, prefix: str, uri: str):
|
|
17
|
+
def __init__(self, prefix: str, uri: str, promoted: bool = False):
|
|
18
18
|
"""Initialize the Namespace class"""
|
|
19
19
|
|
|
20
20
|
if not isinstance(prefix, str):
|
|
@@ -27,6 +27,11 @@ class Namespace(object):
|
|
|
27
27
|
|
|
28
28
|
self._uri = uri
|
|
29
29
|
|
|
30
|
+
if not isinstance(promoted, bool):
|
|
31
|
+
raise TypeError("The 'promoted' argument must have a boolean value!")
|
|
32
|
+
|
|
33
|
+
self._promoted = promoted
|
|
34
|
+
|
|
30
35
|
def __str__(self) -> str:
|
|
31
36
|
"""Return a string representation of the class for debugging purposes."""
|
|
32
37
|
|
|
@@ -89,7 +94,7 @@ class Namespace(object):
|
|
|
89
94
|
def copy(self) -> Namespace:
|
|
90
95
|
"""Create an independent copy of the current Namespace instance."""
|
|
91
96
|
|
|
92
|
-
return Namespace(prefix=self.prefix, uri=self.uri)
|
|
97
|
+
return Namespace(prefix=self.prefix, uri=self.uri, promoted=self.promoted)
|
|
93
98
|
|
|
94
99
|
@property
|
|
95
100
|
def promoted(self) -> bool:
|
maxml/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.5
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maxml
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: A streamlined pure Python XML serializer.
|
|
5
5
|
Author: Daniel Sissman
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,9 +19,9 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: classicist==1.0.*
|
|
22
|
-
Requires-Dist: enumerific==1.
|
|
22
|
+
Requires-Dist: enumerific==1.1.*
|
|
23
23
|
Provides-Extra: development
|
|
24
|
-
Requires-Dist: black==
|
|
24
|
+
Requires-Dist: black==26.1.*; extra == "development"
|
|
25
25
|
Requires-Dist: pytest==8.3.*; extra == "development"
|
|
26
26
|
Requires-Dist: pytest-codeblocks==0.17.0; extra == "development"
|
|
27
27
|
Provides-Extra: distribution
|
|
@@ -115,10 +115,10 @@ The `Element` class constructor `Element(...)` takes the following arguments:
|
|
|
115
115
|
|
|
116
116
|
The `Element` class provides the following methods:
|
|
117
117
|
|
|
118
|
-
* `register_namespace(prefix: str, uri: str
|
|
119
|
-
supports registering namespaces globally for the
|
|
120
|
-
on whether the method is called on the class
|
|
121
|
-
specific instance of the class.
|
|
118
|
+
* `register_namespace(prefix: str, uri: str, promoted: bool = False)` –
|
|
119
|
+
The `register_namespace()` method supports registering namespaces globally for the
|
|
120
|
+
module or per instance depending on whether the method is called on the class
|
|
121
|
+
directly or whether it is called on a specific instance of the class.
|
|
122
122
|
|
|
123
123
|
If a namespace is registered globally for the module, the registered namespaces
|
|
124
124
|
become available for use by any instance of the class created within the program
|
|
@@ -132,6 +132,16 @@ The `Element` class provides the following methods:
|
|
|
132
132
|
|
|
133
133
|
Each namespace consists of a prefix which can be used to prefix element names
|
|
134
134
|
and the URI associated with that namespace prefix.
|
|
135
|
+
|
|
136
|
+
Optionally, a namespace can be marked as being promoted during registration, which
|
|
137
|
+
will result in the namespace being serialized into the XML before any attributes on
|
|
138
|
+
the element. Namespaces that are not marked as being promoted will appear after any
|
|
139
|
+
attributes on the element. Namespace promotion can be enabled for a given namespace
|
|
140
|
+
during registration by passing the optional `promoted` keyword argument with the
|
|
141
|
+
value of `True`. Whether a namespace is marked as promoted or not can be changed
|
|
142
|
+
after registration by changing a `Namespace` entity's `promoted` property value or
|
|
143
|
+
by using the `promote()` and `unpromote()` methods. See the **Namespace Class** for
|
|
144
|
+
more information.
|
|
135
145
|
|
|
136
146
|
For example, the 'rdf' prefix is associated with the following canonical URI:
|
|
137
147
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
@@ -278,6 +288,9 @@ The `Namespace` class constructor `Namespace(...)` takes the following arguments
|
|
|
278
288
|
|
|
279
289
|
* `prefix` (`str`) – The required `prefix` argument sets the namespace prefix.
|
|
280
290
|
* `uri` (`str`) – The required `uri` argument sets the namespace URI.
|
|
291
|
+
* `promoted` (`bool`) – The optional `promoted` argument sets whether the namespace is
|
|
292
|
+
marked as being promoted or not. Promoted namespaces result in the namespace being
|
|
293
|
+
serialized into the XML before any attributes on their associated element.
|
|
281
294
|
|
|
282
295
|
The `Namespace` class provides the following methods:
|
|
283
296
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
maxml/__init__.py,sha256=9wLSTIlZTXinpBr9ABp_PUWhfxubtNM89Iac2VCNet8,150
|
|
2
|
+
maxml/version.txt,sha256=nXE_EpedYoeSULwKIDXj71cxWsQlHoUBnSHHXtcmlyA,5
|
|
3
|
+
maxml/element/__init__.py,sha256=fE8S25ijZORtZMql0w58KONgoybWkkfXynCFNxEPUb4,26394
|
|
4
|
+
maxml/enumerations/__init__.py,sha256=N15XKtEZp2cFwqq_1GXyODqoOE--z9WukZGt_rFur2E,1153
|
|
5
|
+
maxml/exceptions/__init__.py,sha256=qMI3bIXJe6zDXzRnxdW3v6wbxSYfd1oK-9lnxvZzzjQ,38
|
|
6
|
+
maxml/logging/__init__.py,sha256=AMpvZEQH9GIBe8609sMwb2T64rovpkRRCc9rs2kHy8g,52
|
|
7
|
+
maxml/namespace/__init__.py,sha256=EJs0gJClL2Kz0ECtGr8hQzrXOtGxi3RIbLzAoXIufno,4091
|
|
8
|
+
maxml-1.0.5.dist-info/METADATA,sha256=dPUqqC104G7xgyz0jdGGbxx4bszCVVgE-tj1BkPicGw,17165
|
|
9
|
+
maxml-1.0.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
maxml-1.0.5.dist-info/top_level.txt,sha256=ZFK3SmCc04Dzhl9QkO_hVBAEiHwCNrwn8X_PINWE9C4,6
|
|
11
|
+
maxml-1.0.5.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
+
maxml-1.0.5.dist-info/RECORD,,
|
maxml-1.0.3.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
maxml/__init__.py,sha256=9wLSTIlZTXinpBr9ABp_PUWhfxubtNM89Iac2VCNet8,150
|
|
2
|
-
maxml/version.txt,sha256=INLLCW0atBpBQCRtEvB79rjLdD_UgSK3JTLAPUTFwUo,5
|
|
3
|
-
maxml/element/__init__.py,sha256=39X5ncEAT7kdFa9jz-1MVG02O5HaoxcHuFuNUNYswXY,26198
|
|
4
|
-
maxml/enumerations/__init__.py,sha256=N15XKtEZp2cFwqq_1GXyODqoOE--z9WukZGt_rFur2E,1153
|
|
5
|
-
maxml/exceptions/__init__.py,sha256=qMI3bIXJe6zDXzRnxdW3v6wbxSYfd1oK-9lnxvZzzjQ,38
|
|
6
|
-
maxml/logging/__init__.py,sha256=AMpvZEQH9GIBe8609sMwb2T64rovpkRRCc9rs2kHy8g,52
|
|
7
|
-
maxml/namespace/__init__.py,sha256=iZqHWuGi09KtMTr7wHiyTQLXB2TFljUir8wZGLi2b60,3882
|
|
8
|
-
maxml-1.0.3.dist-info/METADATA,sha256=ekfPSZaa565dou1yy4wwqC4fWu264JxFlwqYra-AXpo,16193
|
|
9
|
-
maxml-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
maxml-1.0.3.dist-info/top_level.txt,sha256=ZFK3SmCc04Dzhl9QkO_hVBAEiHwCNrwn8X_PINWE9C4,6
|
|
11
|
-
maxml-1.0.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
-
maxml-1.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|