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
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 |
|
__init__(generator)
Initialize CodeWriter.
Source code in xsdata/codegen/writer.py
27 28 29 |
|
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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
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
71 72 73 74 75 76 77 78 79 |
|
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
81 82 83 84 85 86 87 88 |
|