xsdata.formats.mixins module

class xsdata.formats.mixins.GeneratorResult(path, title, source)[source]

Bases: object

Generator easy access output wrapper.

Parameters
  • path (Path) – file path to be written

  • title (str) – result title for misc usage

  • source (str) – source code/output to be written

path: pathlib.Path
title: str
source: str
class xsdata.formats.mixins.AbstractGenerator(tpl_dir, config)[source]

Bases: object

Abstract code generator class.

Parameters
  • tpl_dir (str) – Templates directory

  • config (GeneratorConfig) – Generator configuration

template(name)[source]

Return the named template from the initialized environment.

Parameters

name (str) –

Return type

Template

module_name(module)[source]

Convert the given module name to match the generator conventions.

Parameters

module (str) –

Return type

str

package_name(package)[source]

Convert the given module name to match the generator conventions.

Parameters

package (str) –

Return type

str

abstract render(classes)[source]

Return a iterator of the generated results.

Parameters

classes (List[Class]) –

Return type

Iterator[GeneratorResult]

classmethod group_by_package(classes)[source]

Group the given list of classes by the target package directory.

Parameters

classes (List[Class]) –

Return type

Dict[Path, List[Class]]

classmethod group_by_module(classes)[source]

Group the given list of classes by the target module directory.

Parameters

classes (List[Class]) –

Return type

Dict[Path, List[Class]]

designate(classes)[source]

Normalize the target package and module names by the given output generator.

Parameters

classes (List[Class]) – a list of codegen class instances