writer
xsdata.codegen.writer
CodeWriter
Code writer class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generator | AbstractGenerator | The code generator instance | required |
Attributes:
Name | Type | Description |
---|---|---|
generators | Dict[str, Type[AbstractGenerator]] | A map of registered code generators |
Source code in xsdata/codegen/writer.py
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 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 |
|
write(classes)
Write the classes to the designated modules.
The classes may be written in the same module or different ones, the entrypoint must create the directory structure write the file outputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classes | List[Class] | A list of class instances | required |
Source code in xsdata/codegen/writer.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
print(classes)
Print the generated code for the given classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classes | List[Class] | A list of class instances | required |
Source code in xsdata/codegen/writer.py
53 54 55 56 57 58 59 60 61 62 63 64 |
|
from_config(config)
classmethod
Instance the code writer from the generator configuration instance.
Validates that the output format is registered as a generator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | GeneratorConfig | The generator configuration instance | required |
Returns:
Type | Description |
---|---|
CodeWriter | A new code writer instance. |
Source code in xsdata/codegen/writer.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
register_generator(name, clazz)
classmethod
Register a generator by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The generator name | required |
clazz | Type[AbstractGenerator] | The generator class | required |
Source code in xsdata/codegen/writer.py
86 87 88 89 90 91 92 93 94 |
|
unregister_generator(name)
classmethod
Remove a generator by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The generator name | required |
Source code in xsdata/codegen/writer.py
96 97 98 99 100 101 102 103 |
|
ruff_code(src_code, file_path)
Run ruff format on the src code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_code | str | The output source code | required |
file_path | Path | The file path the source code will be written to | required |
Returns:
Type | Description |
---|---|
str | The formatted output source code |
Source code in xsdata/codegen/writer.py
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 |
|