xsdata.formats.generators module¶
-
class
xsdata.formats.generators.
AbstractGenerator
[source]¶ Bases:
abc.ABC
-
templates_dir
: Optional[pathlib.Path] = None¶
-
-
class
xsdata.formats.generators.
PythonAbstractGenerator
[source]¶ Bases:
xsdata.formats.generators.AbstractGenerator
,abc.ABC
-
xml_type_map
= {'Element': 'Element', 'Any': 'Wildcard', 'AnyAttribute': 'Attributes', 'Attribute': 'Attribute', None: 'Text'}¶
-
classmethod
process_class
(obj, parents=None)[source]¶ Normalize all class instance fields, extends, name and the inner classes recursively.
-
classmethod
process_attributes
(obj, parents_list)[source]¶ Process class attributes and prevent duplicate attribute names.
-
classmethod
sanitize_attribute_names
(obj)[source]¶ Append xml type to attribute name if it’s not unique in the list.
Prefer keeping intact element attributes.
- Parameters
obj (
Class
) –
-
classmethod
hash_attributes_names
(obj)[source]¶ Replace attribute names with b64 hash of the local name.
This is a last resort to create unique class attribute names.
- Parameters
obj (
Class
) –
-
classmethod
has_duplicate_attrs
(obj)[source]¶ Check if given class includes duplicate attribute names.
-
classmethod
unset_attributes_local_names
(obj)[source]¶ Unset attribute local name when it’s not necessary.
- Examples:
xs:any
xs:anyAttribute
field name is equal to local name
- Parameters
obj (
Class
) –
-
classmethod
type_name
(attr_type)[source]¶ Convert xsd types to python or apply class name conventions after stripping any reference prefix.
-
classmethod
attribute_name
(name)[source]¶ Strip reference prefix and turn to snake case.
If the name is one of the python reserved words append the prefix _value
-
classmethod
enumeration_name
(name)[source]¶ Strip reference prefix and turn to snake case.
If the name is one of the python reserved words append the prefix _value
-
classmethod
attribute_display_type
(attr, parents)[source]¶ Normalize attribute type.
- Steps:
If type alias is present use class name normalization
Otherwise use the type name normalization
Prepend outer class names and quote result for forward references
Wrap the result with List if the field accepts a list of values
Wrap the result with Optional if the field default value is None
-