polyxml 0.2.0__tar.gz → 0.2.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.
- {polyxml-0.2.0 → polyxml-0.2.1}/Cargo.lock +4 -4
- {polyxml-0.2.0 → polyxml-0.2.1}/Cargo.toml +1 -1
- {polyxml-0.2.0 → polyxml-0.2.1}/PKG-INFO +1 -1
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/src/lib.rs +16 -33
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/tests/test_polyxml.py +60 -1
- {polyxml-0.2.0 → polyxml-0.2.1}/pyproject.toml +1 -1
- {polyxml-0.2.0 → polyxml-0.2.1}/README.md +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/Cargo.toml +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/README.md +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/converters.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/error.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/lib.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/parser.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/schema.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/serializer.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/value.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/tests/test_core.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/tests/test_security.rs +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/Cargo.toml +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/README.md +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/python/polyxml/__init__.py +0 -0
- {polyxml-0.2.0 → polyxml-0.2.1}/python/polyxml/py.typed +0 -0
|
@@ -396,7 +396,7 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
|
|
396
396
|
|
|
397
397
|
[[package]]
|
|
398
398
|
name = "polyxml"
|
|
399
|
-
version = "0.2.
|
|
399
|
+
version = "0.2.1"
|
|
400
400
|
dependencies = [
|
|
401
401
|
"criterion",
|
|
402
402
|
"lexical-core",
|
|
@@ -409,14 +409,14 @@ dependencies = [
|
|
|
409
409
|
|
|
410
410
|
[[package]]
|
|
411
411
|
name = "polyxml-c"
|
|
412
|
-
version = "0.2.
|
|
412
|
+
version = "0.2.1"
|
|
413
413
|
dependencies = [
|
|
414
414
|
"polyxml",
|
|
415
415
|
]
|
|
416
416
|
|
|
417
417
|
[[package]]
|
|
418
418
|
name = "polyxml-js"
|
|
419
|
-
version = "0.2.
|
|
419
|
+
version = "0.2.1"
|
|
420
420
|
dependencies = [
|
|
421
421
|
"napi",
|
|
422
422
|
"napi-build",
|
|
@@ -426,7 +426,7 @@ dependencies = [
|
|
|
426
426
|
|
|
427
427
|
[[package]]
|
|
428
428
|
name = "polyxml-python"
|
|
429
|
-
version = "0.2.
|
|
429
|
+
version = "0.2.1"
|
|
430
430
|
dependencies = [
|
|
431
431
|
"lexical-core",
|
|
432
432
|
"polyxml",
|
|
@@ -372,48 +372,28 @@ fn convert_scalar_to_py<'py>(
|
|
|
372
372
|
let dec = decimal_cls.call1((s.as_str(),))?;
|
|
373
373
|
return Ok(dec.unbind());
|
|
374
374
|
}
|
|
375
|
-
"XmlDate" => {
|
|
376
|
-
if let Ok(
|
|
377
|
-
|
|
378
|
-
if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
|
|
379
|
-
return Ok(val.unbind());
|
|
380
|
-
}
|
|
381
|
-
}
|
|
375
|
+
"XmlDate" | "XmlDateTime" | "XmlTime" => {
|
|
376
|
+
if let Ok(val) = target_type.call_method1("from_string", (s.as_str(),)) {
|
|
377
|
+
return Ok(val.unbind());
|
|
382
378
|
}
|
|
383
|
-
if let Ok(datetime_mod) = py.import_bound("datetime") {
|
|
384
|
-
if let Ok(cls) = datetime_mod.getattr("date") {
|
|
385
|
-
if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
|
|
386
|
-
return Ok(val.unbind());
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
"XmlDateTime" => {
|
|
392
379
|
if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
|
|
393
|
-
if let Ok(cls) = datatype_mod.getattr(
|
|
380
|
+
if let Ok(cls) = datatype_mod.getattr(type_name.as_str()) {
|
|
394
381
|
if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
|
|
395
382
|
return Ok(val.unbind());
|
|
396
383
|
}
|
|
397
384
|
}
|
|
398
385
|
}
|
|
399
|
-
if let Ok(
|
|
400
|
-
|
|
401
|
-
if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
|
|
402
|
-
return Ok(val.unbind());
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
"XmlTime" => {
|
|
408
|
-
if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
|
|
409
|
-
if let Ok(cls) = datatype_mod.getattr("XmlTime") {
|
|
410
|
-
if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
|
|
411
|
-
return Ok(val.unbind());
|
|
412
|
-
}
|
|
413
|
-
}
|
|
386
|
+
if let Ok(val) = target_type.call1((s.as_str(),)) {
|
|
387
|
+
return Ok(val.unbind());
|
|
414
388
|
}
|
|
389
|
+
let mod_name = match type_name.as_str() {
|
|
390
|
+
"XmlDate" => "date",
|
|
391
|
+
"XmlDateTime" => "datetime",
|
|
392
|
+
"XmlTime" => "time",
|
|
393
|
+
_ => "",
|
|
394
|
+
};
|
|
415
395
|
if let Ok(datetime_mod) = py.import_bound("datetime") {
|
|
416
|
-
if let Ok(cls) = datetime_mod.getattr(
|
|
396
|
+
if let Ok(cls) = datetime_mod.getattr(mod_name) {
|
|
417
397
|
if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
|
|
418
398
|
return Ok(val.unbind());
|
|
419
399
|
}
|
|
@@ -421,6 +401,9 @@ fn convert_scalar_to_py<'py>(
|
|
|
421
401
|
}
|
|
422
402
|
}
|
|
423
403
|
"XmlDuration" => {
|
|
404
|
+
if let Ok(val) = target_type.call1((s.as_str(),)) {
|
|
405
|
+
return Ok(val.unbind());
|
|
406
|
+
}
|
|
424
407
|
if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
|
|
425
408
|
if let Ok(cls) = datatype_mod.getattr("XmlDuration") {
|
|
426
409
|
if let Ok(val) = cls.call1((s.as_str(),)) {
|
|
@@ -6,7 +6,66 @@ from enum import Enum
|
|
|
6
6
|
|
|
7
7
|
import pytest
|
|
8
8
|
from pydantic import BaseModel, Field
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
from pyxsdata.models.datatype import XmlDate, XmlDateTime, XmlDuration, XmlTime
|
|
12
|
+
except ImportError:
|
|
13
|
+
|
|
14
|
+
class XmlDate:
|
|
15
|
+
|
|
16
|
+
def __init__(self, val: str):
|
|
17
|
+
self.val = val
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_string(cls, val: str):
|
|
21
|
+
return cls(val)
|
|
22
|
+
|
|
23
|
+
def __eq__(self, other):
|
|
24
|
+
return isinstance(other, XmlDate) and self.val == other.val
|
|
25
|
+
|
|
26
|
+
def __str__(self):
|
|
27
|
+
return self.val
|
|
28
|
+
|
|
29
|
+
class XmlDateTime:
|
|
30
|
+
|
|
31
|
+
def __init__(self, val: str):
|
|
32
|
+
self.val = val
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_string(cls, val: str):
|
|
36
|
+
return cls(val)
|
|
37
|
+
|
|
38
|
+
def __eq__(self, other):
|
|
39
|
+
return isinstance(other, XmlDateTime) and self.val == other.val
|
|
40
|
+
|
|
41
|
+
def __str__(self):
|
|
42
|
+
return self.val
|
|
43
|
+
|
|
44
|
+
class XmlTime:
|
|
45
|
+
|
|
46
|
+
def __init__(self, val: str):
|
|
47
|
+
self.val = val
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def from_string(cls, val: str):
|
|
51
|
+
return cls(val)
|
|
52
|
+
|
|
53
|
+
def __eq__(self, other):
|
|
54
|
+
return isinstance(other, XmlTime) and self.val == other.val
|
|
55
|
+
|
|
56
|
+
def __str__(self):
|
|
57
|
+
return self.val
|
|
58
|
+
|
|
59
|
+
class XmlDuration:
|
|
60
|
+
|
|
61
|
+
def __init__(self, val: str):
|
|
62
|
+
self.val = val
|
|
63
|
+
|
|
64
|
+
def __eq__(self, other):
|
|
65
|
+
return isinstance(other, XmlDuration) and self.val == other.val
|
|
66
|
+
|
|
67
|
+
def __str__(self):
|
|
68
|
+
return self.val
|
|
10
69
|
|
|
11
70
|
import polyxml
|
|
12
71
|
|
|
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
|
|
File without changes
|