Skip to content

Commit

Permalink
fix for newer xmlschema (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Aug 25, 2021
1 parent 1a97fbe commit 4bc4cd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include_package_data = True
python_requires = >=3.7
install_requires =
pydantic[email]>=1.0
xmlschema==1.4.1
xmlschema>=1.4.1,<2
Pint>=0.15

[options.entry_points]
Expand Down
12 changes: 11 additions & 1 deletion src/ome_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from xmlschema.validators import (
XsdAnyAttribute,
XsdAnyElement,
XsdAtomicBuiltin,
XsdAttribute,
XsdComponent,
XsdElement,
Expand Down Expand Up @@ -638,7 +639,7 @@ def to_numpydoc_param(self) -> Parameter:

@property
def is_builtin_type(self) -> bool:
return hasattr(self.type, "python_type")
return isinstance(self.type, XsdAtomicBuiltin)

@property
def is_decimal(self) -> bool:
Expand Down Expand Up @@ -923,6 +924,15 @@ def _simple_class(self) -> List[str]:
return make_color()
if self.is_enum:
return make_enum(self.elem)
# Hack for xmlschema > 1.4.1
if self.type.local_name == "base64Binary":
return ["class base64Binary(ConstrainedStr):", " pass"]
if self.type.local_name == "Hex40":
return [
"class Hex40(ConstrainedStr):",
" min_length = 20",
" max_length = 20",
]

lines = []
if self.type.base_type.is_restriction():
Expand Down
4 changes: 2 additions & 2 deletions src/ome_types/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import xmlschema
from elementpath.datatypes import DateTime10
from xmlschema import XMLSchemaParseError
from xmlschema.converters import ElementData, XMLSchemaConverter
from xmlschema import ElementData, XMLSchemaParseError
from xmlschema.converters import XMLSchemaConverter
from xmlschema.documents import XMLSchemaValueError

from ome_types._base_type import OMEType
Expand Down

0 comments on commit 4bc4cd3

Please sign in to comment.