xsdata.formats.dataclass.filters module¶
-
class
xsdata.formats.dataclass.filters.Filters(class_aliases=<factory>, field_aliases=<factory>, package_aliases=<factory>, module_aliases=<factory>, class_case=<function pascal_case>, field_case=<function snake_case>, package_case=<function snake_case>, module_case=<function snake_case>, class_safe_prefix='type', field_safe_prefix='value', package_safe_prefix='pkg', module_safe_prefix='mod')[source]¶ Bases:
object- Parameters
class_aliases (
Dict) –field_aliases (
Dict) –package_aliases (
Dict) –module_aliases (
Dict) –class_case (
Callable) –field_case (
Callable) –package_case (
Callable) –module_case (
Callable) –class_safe_prefix (
str) –field_safe_prefix (
str) –package_safe_prefix (
str) –module_safe_prefix (
str) –
-
class_aliases: Dict¶
-
field_aliases: Dict¶
-
package_aliases: Dict¶
-
module_aliases: Dict¶
-
cache: Dict¶
-
class_name(name)[source]¶ Convert the given string to a class name according to the selected conventions or use an existing alias.
-
field_name(name)[source]¶ Convert the given string to a field name according to the selected conventions or use an existing alias.
-
module_name(name)[source]¶ Convert the given string to a module name according to the selected conventions or use an existing alias.
-
package_name(name)[source]¶ Convert the given string to a package name according to the selected conventions or use an existing alias.
-
field_metadata(attr, parent_namespace, parents)[source]¶ Return a metadata dictionary for the given attribute.
-
field_choices(attr, parent_namespace, parents)[source]¶ Return a list of metadata dictionaries for the choices of the given attribute.
Return None if attribute has no choices.
-
classmethod
format_metadata(data, level=0, pattern=False)[source]¶ Prettify field metadata for code generation.
-
class_docstring(obj, enum=False)[source]¶ Generate docstring for the given class and the constructor arguments.
-
field_default_value(attr, ns_map=None)[source]¶ Generate the field default value/factory for the given attribute.
-
choice_type(choice, parents)[source]¶ Generate type hints for the given choice.
Choices support a subset of features from normal attributes. First of all we don’t have a proper type hint but a type metadata key. That’s why we always need to wrap as Type[xxx]. The second big difference is that our choice belongs to a compound field that might be a list, that’s why list restriction is also ignored.
- Parameters
choice (
AttrChoice) –
- Return type
-
classmethod
default_imports(output)[source]¶ Generate the default imports for the given package output.
-
classmethod
from_config(config)[source]¶ - Parameters
config (
GeneratorConfig) –- Return type