File: config.py

package info (click to toggle)
python-xsdata 24.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,936 kB
  • sloc: python: 29,257; xml: 404; makefile: 27; sh: 6
file content (56 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
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
from typing import Callable, Dict, Optional


class SerializerConfig:
    """
    Serializer configuration options.

    Some options are not applicable for both xml or json documents.

    :param encoding: Text encoding
    :param xml_version: XML Version number (1.0|1.1)
    :param xml_declaration: Generate XML declaration
    :param pretty_print: Enable pretty output
    :param pretty_print_indent: Indentation string for each indent level
    :param ignore_default_attributes: Ignore optional attributes with
        default values
    :param schema_location: xsi:schemaLocation attribute value
    :param no_namespace_schema_location: xsi:noNamespaceSchemaLocation
        attribute value
    :param globalns: Dictionary containing global variables to extend or
        overwrite for typing
    """

    __slots__ = (
        "encoding",
        "xml_version",
        "xml_declaration",
        "pretty_print",
        "pretty_print_indent",
        "ignore_default_attributes",
        "schema_location",
        "no_namespace_schema_location",
        "globalns",
    )

    def __init__(
        self,
        encoding: str = "UTF-8",
        xml_version: str = "1.0",
        xml_declaration: bool = True,
        pretty_print: bool = False,
        pretty_print_indent: Optional[str] = None,
        ignore_default_attributes: bool = False,
        schema_location: Optional[str] = None,
        no_namespace_schema_location: Optional[str] = None,
        globalns: Optional[Dict[str, Callable]] = None,
    ):
        self.encoding = encoding
        self.xml_version = xml_version
        self.xml_declaration = xml_declaration
        self.pretty_print = pretty_print
        self.pretty_print_indent = pretty_print_indent
        self.ignore_default_attributes = ignore_default_attributes
        self.schema_location = schema_location
        self.no_namespace_schema_location = no_namespace_schema_location
        self.globalns = globalns