detect_circular_references
xsdata.codegen.handlers.detect_circular_references
DetectCircularReferences
Bases: RelativeHandlerInterface
Accurately detect circular dependencies between classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
ContainerInterface
|
The class container instance |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
reference_types |
dict[int, list[AttrType]]
|
A map of class refs to dependency types |
Source code in xsdata/codegen/handlers/detect_circular_references.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
__init__(container)
Initialize the class.
Source code in xsdata/codegen/handlers/detect_circular_references.py
22 23 24 25 | |
process(target)
Go through all the attr types and find circular references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Class
|
The class to inspect and update |
required |
Source code in xsdata/codegen/handlers/detect_circular_references.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
process_types(types, class_reference)
Go through the types and find circular references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
types
|
list[AttrType]
|
A list attr/choice type instances |
required |
class_reference
|
int
|
The parent attr/choice class reference |
required |
Source code in xsdata/codegen/handlers/detect_circular_references.py
42 43 44 45 46 47 48 49 50 51 | |
is_circular(start, stop)
Detect if the start reference leads to the stop reference.
The procedure is a dfs search to avoid max recursion errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
int
|
The attr type reference |
required |
stop
|
int
|
The parent class reference |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the start reference leads back to the stop reference. |
Source code in xsdata/codegen/handlers/detect_circular_references.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
build_reference_types()
Build the reference types mapping.
Source code in xsdata/codegen/handlers/detect_circular_references.py
82 83 84 85 86 87 88 89 90 91 92 93 | |