rename_duplicate_classes
xsdata.codegen.handlers.rename_duplicate_classes
RenameDuplicateClasses
Bases: ContainerHandlerInterface
Resolve class name conflicts depending on the output structure style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container | ContainerInterface | The class container instance | required |
Attributes:
Name | Type | Description |
---|---|---|
use_names | Whether names or qualified names should be used to group classes | |
merges | dict[int, int] | The renamed instructions applied at the end |
merges | dict[int, int] | The merge instructions applied at the end |
reserved | set[str] | The reserved class names or qualified names |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
run()
Detect and resolve class name conflicts.
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
should_use_names()
Determine if names or qualified names should be used for detection.
Strict unique names
- Single package
- Clustered packages
- All classes have the same source location.
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
56 57 58 59 60 61 62 63 64 65 66 67 |
|
merge_classes(classes)
Remove the duplicate classes and update all references.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classes | list[Class] | A list of duplicate classes | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
69 70 71 72 73 74 75 76 77 78 79 80 |
|
rename_classes(classes)
Rename the classes in the list.
Cases
- Two classes, one abstract append the abstract suffix
- One element, add numeric suffixes to the rest of the classes
- Add numeric suffixes to all classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classes | list[Class] | A list of classes with duplicate names | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
add_abstract_suffix(target)
Add the abstract suffix to class name.
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
102 103 104 105 |
|
add_numeric_suffix(target)
Find the next available class name.
Save the original name in the class metadata and update the class qualified name and all classes that depend on the target class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance to rename | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
rename_class(target, new_qname)
Update the class qualified name and update references.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class to update | required |
new_qname | str | The new class qualified name | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
next_qname(namespace, name)
Use int suffixes to get the next available qualified name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace | str | The class namespace | required |
name | str | The class name | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
get_reserved()
Build the reserved names or qualified names of the container.
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
155 156 157 158 159 160 161 |
|
update_references(target)
Search and update the target class for renamed and merged references.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Class | The target class instance to inspect and update | required |
Source code in xsdata/codegen/handlers/rename_duplicate_classes.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|