xsdata.formats.generators module

class xsdata.formats.generators.AbstractGenerator[source]

Bases: abc.ABC

templates_dir: Optional[pathlib.Path] = None
template(name)[source]
Return type

Template

abstract render(classes)[source]
Return type

Iterator[Tuple[Path, str, str]]

classmethod module_name(name)[source]
Return type

str

classmethod package_name(name)[source]
Return type

str

class xsdata.formats.generators.PythonAbstractGenerator[source]

Bases: xsdata.formats.generators.AbstractGenerator, abc.ABC

classmethod process_class(obj, parents=None)[source]

Normalize all class instance fields, extends, name and the inner classes recursively.

Return type

Class

classmethod process_enumerations(obj)[source]
classmethod process_attributes(obj, parents_list)[source]
classmethod process_extension(extension)[source]
classmethod process_attribute(attr, parents)[source]

Normalize attribute properties.

Return type

None

classmethod process_import(package)[source]

Normalize import package properties.

Return type

Package

classmethod module_name(name)[source]
Return type

str

classmethod package_name(name)[source]
Return type

str

classmethod class_name(name)[source]

Convert class names to pascal case.

Return type

str

classmethod type_name(attr_type)[source]

Convert xsd types to python or apply class name conventions after stripping any reference prefix.

Return type

str

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

Return type

str

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

Return type

str

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

Return type

str

classmethod attribute_default(attr)[source]

Normalize default value/factory by the attribute type.

Return type

Optional[Any]