maxml 1.0.0__tar.gz → 1.0.2__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.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: hybridmethod==1.0.*
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's and begin creating your XML document:
52
+ To use the MaXML library, import the library and begin creating your XML document:
52
53
 
53
54
  ```python
54
55
  import maxml
@@ -18,7 +18,7 @@ using `pip` via the `pip install` command by entering the following into your sh
18
18
 
19
19
  ### Example Usage
20
20
 
21
- To use the MaXML library, import the library's and begin creating your XML document:
21
+ To use the MaXML library, import the library and begin creating your XML document:
22
22
 
23
23
  ```python
24
24
  import maxml
@@ -1,2 +1,3 @@
1
1
  # MaXML Library: Runtime Dependencies
2
- hybridmethod==1.0.*
2
+ classicist==1.0.*
3
+ enumerific==1.0.*
@@ -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 hybridmethod import hybridmethod
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.warning(
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
- raise ValueError(
148
- f"No namespace has been registered for the '{prefix}' prefix associated with the '{name}' element!"
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
- self._attributes[name] = value
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
@@ -0,0 +1 @@
1
+ 1.0.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maxml
3
- Version: 1.0.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: hybridmethod==1.0.*
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's and begin creating your XML document:
52
+ To use the MaXML library, import the library and begin creating your XML document:
52
53
 
53
54
  ```python
54
55
  import maxml
@@ -1,4 +1,5 @@
1
- hybridmethod==1.0.*
1
+ classicist==1.0.*
2
+ enumerific==1.0.*
2
3
 
3
4
  [development]
4
5
  black==24.10.*
@@ -1 +0,0 @@
1
- 1.0.0
File without changes
File without changes
File without changes
File without changes
File without changes