maxml 1.0.0__tar.gz → 1.0.1__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.
- {maxml-1.0.0 → maxml-1.0.1}/PKG-INFO +1 -1
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml/element/__init__.py +36 -4
- maxml-1.0.1/source/maxml/version.txt +1 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/PKG-INFO +1 -1
- maxml-1.0.0/source/maxml/version.txt +0 -1
- {maxml-1.0.0 → maxml-1.0.1}/README.md +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/pyproject.toml +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/requirements.development.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/requirements.distribution.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/requirements.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/setup.cfg +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml/__init__.py +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml/logging/__init__.py +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml/namespace/__init__.py +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/SOURCES.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/dependency_links.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/requires.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/top_level.txt +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/source/maxml.egg-info/zip-safe +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/tests/test_element.py +0 -0
- {maxml-1.0.0 → maxml-1.0.1}/tests/test_namespace.py +0 -0
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.0
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|