polyxml 0.6.0__tar.gz → 0.8.0__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.
- {polyxml-0.6.0 → polyxml-0.8.0}/Cargo.lock +4 -4
- {polyxml-0.6.0 → polyxml-0.8.0}/Cargo.toml +1 -1
- {polyxml-0.6.0 → polyxml-0.8.0}/PKG-INFO +1 -1
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/parser.rs +12 -3
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/serializer.rs +11 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-python/src/lib.rs +14 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-python/tests/test_polyxml.py +19 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/pyproject.toml +1 -1
- {polyxml-0.6.0 → polyxml-0.8.0}/README.md +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/Cargo.toml +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/README.md +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/converters.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/error.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/lib.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/schema.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/src/value.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/tests/test_core.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-core/tests/test_security.rs +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-python/Cargo.toml +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/crates/polyxml-python/README.md +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/python/polyxml/AGENT_GUIDE.md +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/python/polyxml/__init__.py +0 -0
- {polyxml-0.6.0 → polyxml-0.8.0}/python/polyxml/py.typed +0 -0
|
@@ -395,7 +395,7 @@ dependencies = [
|
|
|
395
395
|
|
|
396
396
|
[[package]]
|
|
397
397
|
name = "polyxml"
|
|
398
|
-
version = "0.
|
|
398
|
+
version = "0.8.0"
|
|
399
399
|
dependencies = [
|
|
400
400
|
"criterion",
|
|
401
401
|
"lexical-core",
|
|
@@ -408,14 +408,14 @@ dependencies = [
|
|
|
408
408
|
|
|
409
409
|
[[package]]
|
|
410
410
|
name = "polyxml-c"
|
|
411
|
-
version = "0.
|
|
411
|
+
version = "0.8.0"
|
|
412
412
|
dependencies = [
|
|
413
413
|
"polyxml",
|
|
414
414
|
]
|
|
415
415
|
|
|
416
416
|
[[package]]
|
|
417
417
|
name = "polyxml-js"
|
|
418
|
-
version = "0.
|
|
418
|
+
version = "0.8.0"
|
|
419
419
|
dependencies = [
|
|
420
420
|
"napi",
|
|
421
421
|
"napi-build",
|
|
@@ -425,7 +425,7 @@ dependencies = [
|
|
|
425
425
|
|
|
426
426
|
[[package]]
|
|
427
427
|
name = "polyxml-python"
|
|
428
|
-
version = "0.
|
|
428
|
+
version = "0.8.0"
|
|
429
429
|
dependencies = [
|
|
430
430
|
"lexical-core",
|
|
431
431
|
"polyxml",
|
|
@@ -69,9 +69,18 @@ impl StackFrame {
|
|
|
69
69
|
if let Some(ref text_buf) = self.frame_text_buf {
|
|
70
70
|
if !text_buf.is_empty() {
|
|
71
71
|
let field = &self.schema.fields[text_idx];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
match &field.val_type {
|
|
73
|
+
ValueType::Scalar(st) => {
|
|
74
|
+
let val = ValueConverter::parse_scalar(st, text_buf, &field.name)?;
|
|
75
|
+
obj.insert(field.name.clone(), val);
|
|
76
|
+
}
|
|
77
|
+
ValueType::List(inner) => {
|
|
78
|
+
if let ValueType::Scalar(st) = &**inner {
|
|
79
|
+
let val = ValueConverter::parse_scalar(st, text_buf, &field.name)?;
|
|
80
|
+
obj.insert(field.name.clone(), PolyValue::List(vec![val]));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
_ => {}
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
}
|
|
@@ -93,6 +93,17 @@ impl XmlSerializer {
|
|
|
93
93
|
.write_event(Event::Text(BytesText::new(text_content)))
|
|
94
94
|
.map_err(|e| PolyXmlError::SerializationError(e.to_string()))?;
|
|
95
95
|
}
|
|
96
|
+
} else if let PolyValue::List(items) = val {
|
|
97
|
+
for item in items {
|
|
98
|
+
let mut item_buf = [0u8; lexical_core::BUFFER_SIZE];
|
|
99
|
+
if let Some(text_content) = Self::format_scalar_to(item, &mut item_buf) {
|
|
100
|
+
if !text_content.is_empty() {
|
|
101
|
+
writer
|
|
102
|
+
.write_event(Event::Text(BytesText::new(text_content)))
|
|
103
|
+
.map_err(|e| PolyXmlError::SerializationError(e.to_string()))?;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
}
|
|
@@ -216,6 +216,13 @@ fn extract_schema_from_class<'py>(
|
|
|
216
216
|
match t_str.as_str() {
|
|
217
217
|
"Attribute" => kind = FieldKind::Attribute,
|
|
218
218
|
"Text" => kind = FieldKind::Text,
|
|
219
|
+
"Wildcard" => {
|
|
220
|
+
if let Ok(m_mixed) = m.get_item("mixed") {
|
|
221
|
+
if m_mixed.extract::<bool>().unwrap_or(false) {
|
|
222
|
+
kind = FieldKind::Text;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
219
226
|
_ => kind = FieldKind::Element,
|
|
220
227
|
}
|
|
221
228
|
}
|
|
@@ -264,6 +271,13 @@ fn extract_schema_from_class<'py>(
|
|
|
264
271
|
match t_str.as_str() {
|
|
265
272
|
"Attribute" => kind = FieldKind::Attribute,
|
|
266
273
|
"Text" => kind = FieldKind::Text,
|
|
274
|
+
"Wildcard" => {
|
|
275
|
+
if let Ok(m_mixed) = meta.get_item("mixed") {
|
|
276
|
+
if m_mixed.extract::<bool>().unwrap_or(false) {
|
|
277
|
+
kind = FieldKind::Text;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
267
281
|
_ => kind = FieldKind::Element,
|
|
268
282
|
}
|
|
269
283
|
}
|
|
@@ -542,3 +542,22 @@ def test_binary_serialization_loads_corrupted_or_non_tagged():
|
|
|
542
542
|
# Non-decodable data to custom type
|
|
543
543
|
with pytest.raises(msgspec.DecodeError):
|
|
544
544
|
polyxml.loads_binary(b"\xc1")
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def test_mixed_content_wildcard_dataclass():
|
|
548
|
+
@dataclass
|
|
549
|
+
class MixedNode:
|
|
550
|
+
lang: str | None = field(default=None, metadata={"type": "Attribute"})
|
|
551
|
+
content: list[object] = field(
|
|
552
|
+
default_factory=list,
|
|
553
|
+
metadata={"type": "Wildcard", "mixed": True},
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
xml = '<MixedNode lang="en">Sample Text Content</MixedNode>'
|
|
557
|
+
decoded = polyxml.deserialize(xml.encode("utf-8"), MixedNode)
|
|
558
|
+
assert decoded.lang == "en"
|
|
559
|
+
assert decoded.content == ["Sample Text Content"]
|
|
560
|
+
|
|
561
|
+
serialized = polyxml.serialize(decoded)
|
|
562
|
+
assert b"Sample Text Content" in serialized
|
|
563
|
+
assert b'lang="en"' in serialized
|
|
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
|