maxml 1.0.4__tar.gz → 1.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxml
3
- Version: 1.0.4
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.0.*
22
+ Requires-Dist: enumerific==1.1.*
23
23
  Provides-Extra: development
24
- Requires-Dist: black==24.10.*; extra == "development"
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
@@ -133,11 +133,15 @@ The `Element` class provides the following methods:
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
135
 
136
- Optionally, a namespace can be marked as promoted during registration, which will
137
- result in the namespace being serialized into the XML before any attributes on the
138
- element. Namespaces that are not marked as promoted will appear after attributes.
139
- Namespace promotion can be enabled for a given namespace during registration by
140
- passing the optional `promoted` keyword argument with the value of `True`.
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.
141
145
 
142
146
  For example, the 'rdf' prefix is associated with the following canonical URI:
143
147
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -284,6 +288,9 @@ The `Namespace` class constructor `Namespace(...)` takes the following arguments
284
288
 
285
289
  * `prefix` (`str`) – The required `prefix` argument sets the namespace prefix.
286
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.
287
294
 
288
295
  The `Namespace` class provides the following methods:
289
296
 
@@ -102,11 +102,15 @@ The `Element` class provides the following methods:
102
102
  Each namespace consists of a prefix which can be used to prefix element names
103
103
  and the URI associated with that namespace prefix.
104
104
 
105
- Optionally, a namespace can be marked as promoted during registration, which will
106
- result in the namespace being serialized into the XML before any attributes on the
107
- element. Namespaces that are not marked as promoted will appear after attributes.
108
- Namespace promotion can be enabled for a given namespace during registration by
109
- passing the optional `promoted` keyword argument with the value of `True`.
105
+ Optionally, a namespace can be marked as being promoted during registration, which
106
+ will result in the namespace being serialized into the XML before any attributes on
107
+ the element. Namespaces that are not marked as being promoted will appear after any
108
+ attributes on the element. Namespace promotion can be enabled for a given namespace
109
+ during registration by passing the optional `promoted` keyword argument with the
110
+ value of `True`. Whether a namespace is marked as promoted or not can be changed
111
+ after registration by changing a `Namespace` entity's `promoted` property value or
112
+ by using the `promote()` and `unpromote()` methods. See the **Namespace Class** for
113
+ more information.
110
114
 
111
115
  For example, the 'rdf' prefix is associated with the following canonical URI:
112
116
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -253,6 +257,9 @@ The `Namespace` class constructor `Namespace(...)` takes the following arguments
253
257
 
254
258
  * `prefix` (`str`) – The required `prefix` argument sets the namespace prefix.
255
259
  * `uri` (`str`) – The required `uri` argument sets the namespace URI.
260
+ * `promoted` (`bool`) – The optional `promoted` argument sets whether the namespace is
261
+ marked as being promoted or not. Promoted namespaces result in the namespace being
262
+ serialized into the XML before any attributes on their associated element.
256
263
 
257
264
  The `Namespace` class provides the following methods:
258
265
 
@@ -1,4 +1,4 @@
1
1
  # MaXML Library: Development & Test Dependencies
2
- black==24.10.*
2
+ black==26.1.*
3
3
  pytest==8.3.*
4
4
  pytest-codeblocks==0.17.0
@@ -1,3 +1,3 @@
1
1
  # MaXML Library: Runtime Dependencies
2
2
  classicist==1.0.*
3
- enumerific==1.0.*
3
+ enumerific==1.1.*
@@ -122,7 +122,7 @@ class Element(object):
122
122
  prefix: str = None
123
123
 
124
124
  if ":" in name:
125
- (prefix, basename) = name.split(":", maxsplit=1)
125
+ prefix, basename = name.split(":", maxsplit=1)
126
126
 
127
127
  self._prefix: str = prefix
128
128
 
@@ -94,7 +94,7 @@ class Namespace(object):
94
94
  def copy(self) -> Namespace:
95
95
  """Create an independent copy of the current Namespace instance."""
96
96
 
97
- return Namespace(prefix=self.prefix, uri=self.uri)
97
+ return Namespace(prefix=self.prefix, uri=self.uri, promoted=self.promoted)
98
98
 
99
99
  @property
100
100
  def promoted(self) -> bool:
@@ -0,0 +1 @@
1
+ 1.0.5
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxml
3
- Version: 1.0.4
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.0.*
22
+ Requires-Dist: enumerific==1.1.*
23
23
  Provides-Extra: development
24
- Requires-Dist: black==24.10.*; extra == "development"
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
@@ -133,11 +133,15 @@ The `Element` class provides the following methods:
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
135
 
136
- Optionally, a namespace can be marked as promoted during registration, which will
137
- result in the namespace being serialized into the XML before any attributes on the
138
- element. Namespaces that are not marked as promoted will appear after attributes.
139
- Namespace promotion can be enabled for a given namespace during registration by
140
- passing the optional `promoted` keyword argument with the value of `True`.
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.
141
145
 
142
146
  For example, the 'rdf' prefix is associated with the following canonical URI:
143
147
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -284,6 +288,9 @@ The `Namespace` class constructor `Namespace(...)` takes the following arguments
284
288
 
285
289
  * `prefix` (`str`) – The required `prefix` argument sets the namespace prefix.
286
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.
287
294
 
288
295
  The `Namespace` class provides the following methods:
289
296
 
@@ -1,8 +1,8 @@
1
1
  classicist==1.0.*
2
- enumerific==1.0.*
2
+ enumerific==1.1.*
3
3
 
4
4
  [development]
5
- black==24.10.*
5
+ black==26.1.*
6
6
  pytest==8.3.*
7
7
  pytest-codeblocks==0.17.0
8
8
 
@@ -463,6 +463,56 @@ def test_maxml_special_tostring(data: callable):
463
463
  assert string == compare
464
464
 
465
465
 
466
+ def test_maxml_namespace_promotion(data: callable):
467
+ """Check promotion of registered namespaces works as expected"""
468
+
469
+ # Register a class level namespace
470
+ maxml.Element.register_namespace(
471
+ prefix="xy", uri="http://namespace.example.org/xy", promoted=True
472
+ )
473
+
474
+ # Create a new top-level element
475
+ element = maxml.Element(name="xy:test")
476
+
477
+ # Ensure that the Element object's type is as expected
478
+ assert isinstance(element, maxml.Element)
479
+
480
+ # Ensure that the Element object's namespace type is as expected
481
+ assert isinstance(element.namespace, maxml.Namespace)
482
+ assert element.namespace.prefix == "xy"
483
+ assert element.namespace.uri == "http://namespace.example.org/xy"
484
+ assert element.namespace.promoted is True
485
+
486
+ # Set an element attribute
487
+ element.set("xy:id", "1")
488
+
489
+ # Serialise the element to a string
490
+ string: str = element.tostring(pretty=True)
491
+
492
+ assert isinstance(string, str)
493
+
494
+ # Confirm that the promoted namespace was serialised before the attributes
495
+ compare: str = """<xy:test xmlns:xy="http://namespace.example.org/xy" xy:id="1"/>"""
496
+
497
+ assert string == compare
498
+
499
+ # Now mark the namespace as not being promoted to re-test the serialisation below
500
+ element.namespace.promoted = False
501
+
502
+ # Ensure that the promoted status has changed
503
+ assert element.namespace.promoted is False
504
+
505
+ # Serialise the element to a string
506
+ string: str = element.tostring(pretty=True)
507
+
508
+ assert isinstance(string, str)
509
+
510
+ # Confirm that the non-promoted namespace was serialised after the attributes
511
+ compare: str = """<xy:test xy:id="1" xmlns:xy="http://namespace.example.org/xy"/>"""
512
+
513
+ assert string == compare
514
+
515
+
466
516
  def test_maxml_namespace_promotion_non_promoted_namespace(data: callable):
467
517
  """Check promotion of registered namespaces works as expected"""
468
518
 
@@ -1 +0,0 @@
1
- 1.0.4
File without changes
File without changes
File without changes
File without changes