compat
xsdata.formats.dataclass.compat
FieldInfo
Bases: Protocol
A class field info wrapper.
Source code in xsdata/formats/dataclass/compat.py
11 12 13 14 15 16 17 18 |
|
ClassType
Bases: ABC
An interface for class types like attrs, pydantic.
Source code in xsdata/formats/dataclass/compat.py
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 |
|
any_element: Type
abstractmethod
property
Return the AnyElement used to bind wildcard element nodes.
derived_element: Type
abstractmethod
property
Return the DerivedElement used to bind ambiguous element nodes.
any_keys: Set[str]
property
Return the field names of the AnyElement class.
derived_keys: Set[str]
property
Return the field names of the DerivedElement class.
is_model(obj)
abstractmethod
Return whether the given value is binding model.
Source code in xsdata/formats/dataclass/compat.py
46 47 48 |
|
verify_model(obj)
abstractmethod
Verify the given value is a binding model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The input model instance | required |
Raises:
Type | Description |
---|---|
XmlContextError | if not supported |
Source code in xsdata/formats/dataclass/compat.py
50 51 52 53 54 55 56 57 58 59 |
|
get_fields(obj)
abstractmethod
Return the models fields in the correct mro ordering.
Source code in xsdata/formats/dataclass/compat.py
61 62 63 |
|
default_value(field, default=None)
abstractmethod
Return the default value or factory of the given model field.
Source code in xsdata/formats/dataclass/compat.py
65 66 67 |
|
default_choice_value(choice)
abstractmethod
Return the default value or factory of the given model field choice.
Source code in xsdata/formats/dataclass/compat.py
69 70 71 |
|
score_object(obj)
Score a binding model instance by its field values types.
Weights
- None: 0
- str: 1
- *: 1.5
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The input object | required |
Returns:
Type | Description |
---|---|
float | The float score value. |
Source code in xsdata/formats/dataclass/compat.py
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 |
|
ClassTypes
A class types registry.
Attributes:
Name | Type | Description |
---|---|---|
types | Dict[str, ClassType] | A name-instance map of the registered class types |
Source code in xsdata/formats/dataclass/compat.py
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 |
|
register(name, fmt, **_)
Register a class type instance by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the class type | required |
fmt | ClassType | The class type instance | required |
**_ | Any | No idea :( | {} |
Source code in xsdata/formats/dataclass/compat.py
119 120 121 122 123 124 125 126 127 |
|
get_type(name)
Get a class type instance by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The class type name | required |
Returns:
Type | Description |
---|---|
ClassType | The class type instance |
Raises:
Type | Description |
---|---|
KeyError | If the name is not registered. |
Source code in xsdata/formats/dataclass/compat.py
129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
Dataclasses
Bases: ClassType
The dataclasses class type.
Source code in xsdata/formats/dataclass/compat.py
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 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
any_element: Type
property
Return the generic any element class.
derived_element: Type
property
Return the generic derived element class.
is_model(obj)
Return whether the obj is a dataclass model.
Source code in xsdata/formats/dataclass/compat.py
159 160 161 |
|
verify_model(obj)
Validate whether the obj is a dataclass model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The input object to validate. | required |
Raises:
Type | Description |
---|---|
XmlContextError | If it's not a dataclass model. |
Source code in xsdata/formats/dataclass/compat.py
163 164 165 166 167 168 169 170 171 172 173 |
|
get_fields(obj)
Return a dataclass fields iterator.
Source code in xsdata/formats/dataclass/compat.py
175 176 177 |
|
default_value(field, default=None)
Return the default value or factory of the given model field.
Source code in xsdata/formats/dataclass/compat.py
179 180 181 182 183 184 185 186 187 |
|
default_choice_value(choice)
Return the default value or factory of the given model field choice.
Source code in xsdata/formats/dataclass/compat.py
189 190 191 192 193 194 195 |
|