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.
Files changed (23) hide show
  1. {polyxml-0.2.0 → polyxml-0.2.1}/Cargo.lock +4 -4
  2. {polyxml-0.2.0 → polyxml-0.2.1}/Cargo.toml +1 -1
  3. {polyxml-0.2.0 → polyxml-0.2.1}/PKG-INFO +1 -1
  4. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/src/lib.rs +16 -33
  5. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/tests/test_polyxml.py +60 -1
  6. {polyxml-0.2.0 → polyxml-0.2.1}/pyproject.toml +1 -1
  7. {polyxml-0.2.0 → polyxml-0.2.1}/README.md +0 -0
  8. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/Cargo.toml +0 -0
  9. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/README.md +0 -0
  10. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
  11. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/converters.rs +0 -0
  12. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/error.rs +0 -0
  13. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/lib.rs +0 -0
  14. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/parser.rs +0 -0
  15. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/schema.rs +0 -0
  16. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/serializer.rs +0 -0
  17. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/src/value.rs +0 -0
  18. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/tests/test_core.rs +0 -0
  19. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-core/tests/test_security.rs +0 -0
  20. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/Cargo.toml +0 -0
  21. {polyxml-0.2.0 → polyxml-0.2.1}/crates/polyxml-python/README.md +0 -0
  22. {polyxml-0.2.0 → polyxml-0.2.1}/python/polyxml/__init__.py +0 -0
  23. {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.0"
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.0"
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.0"
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.0"
429
+ version = "0.2.1"
430
430
  dependencies = [
431
431
  "lexical-core",
432
432
  "polyxml",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/polyxml-core", "crates/polyxml-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.2.0"
6
+ version = "0.2.1"
7
7
  edition = "2021"
8
8
  rust-version = "1.80"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyxml
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -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(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
377
- if let Ok(cls) = datatype_mod.getattr("XmlDate") {
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("XmlDateTime") {
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(datetime_mod) = py.import_bound("datetime") {
400
- if let Ok(cls) = datetime_mod.getattr("datetime") {
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("time") {
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
- from pyxsdata.models.datatype import XmlDate, XmlDateTime, XmlDuration, XmlTime
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
 
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "High-performance, polyglot XML data-binding engine built in Rust"
9
9
  authors = [
10
10
  { name = "Bailey Nguyen", email = "bailey.tan.nguyen@gmail.com" }
File without changes
File without changes