xsdata.resolver module

class xsdata.resolver.DependenciesResolver(processed=<factory>, aliases=<factory>, imports=<factory>)[source]

Bases: object

processed: Dict[str, str] = None
aliases: Dict[str, str] = None
imports: List[Package] = None
class_list: List[str] = None
class_map: Dict[str, Class] = None
schema: Schema = None
package: str = None
process(classes, schema, package)[source]

Process a list of classes for the given schema and package.

Reset aliases and imports from any previous runs keep the record of the processed class names

sorted_imports()[source]

Return a new sorted by name list of import packages.

Return type

List[Package]

sorted_classes()[source]

Return an iterator of classes property sorted for generation.

Keep track of the class names and their target package name for future classes. Also apply type aliases for the given process run.

Return type

Iterator[Class]

apply_aliases(obj)[source]

Walk the attributes tree and set the type aliases.

Return type

Class

resolve_imports()[source]

Walk all the import class names and add type aliases for name collisions with the given list of classes and build a list of import packages.

Return type

None

add_import(name, package, alias)[source]

Create and append an import package to the list of imports, collect a map of aliases for when we process the list of classes to generate.

Return type

None

add_package(obj)[source]

Add the given class to the map of processed items indexed with the qname of the class and the schema target namespace.

eg {http://www.namespace/name}ClassName

Return type

None

find_package(prefix, name)[source]

Use the schema namespaces map to find the package where the requested class belongs to.

Example:
Return type

str

import_classes()[source]

Return a list of class that need to be imported.

create_class_list(classes)[source]

Use topology sort to return a flat list for all the dependencies.

collect_deps(obj, prefix)[source]

Return a list of dependencies for the given class.

Collect:
  • base classes

  • attribute types

  • recursively go through the inner classes

  • Ignore inner class references

  • Filter the standard xsd types

Return type

Set[str]

static create_class_map(classes)[source]

Index the list of classes by name.