-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serializer option to ignore optional default attributes
- Loading branch information
Showing
14 changed files
with
175 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
from dataclasses import dataclass | ||
from dataclasses import field | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class SerializerConfig: | ||
""" | ||
Serializing configuration options. | ||
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 schema_location: Specify the xsi:schemaLocation attribute value | ||
:param no_namespace_schema_location: Specify the xsi:noNamespaceSchemaLocation | ||
: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 | ||
""" | ||
|
||
encoding: str = field(default="UTF-8") | ||
xml_version: str = field(default="1.0") | ||
xml_declaration: bool = field(default=True) | ||
pretty_print: bool = field(default=False) | ||
schema_location: Optional[str] = field(default=None) | ||
no_namespace_schema_location: Optional[str] = field(default=None) | ||
__slots__ = ( | ||
"encoding", | ||
"xml_version", | ||
"xml_declaration", | ||
"pretty_print", | ||
"ignore_default_attributes", | ||
"schema_location", | ||
"no_namespace_schema_location", | ||
) | ||
|
||
def __init__( | ||
self, | ||
encoding: str = "UTF-8", | ||
xml_version: str = "1.0", | ||
xml_declaration: bool = True, | ||
pretty_print: bool = False, | ||
ignore_default_attributes: bool = False, | ||
schema_location: Optional[str] = None, | ||
no_namespace_schema_location: Optional[str] = None, | ||
): | ||
self.encoding = encoding | ||
self.xml_version = xml_version | ||
self.xml_declaration = xml_declaration | ||
self.pretty_print = pretty_print | ||
self.ignore_default_attributes = ignore_default_attributes | ||
self.schema_location = schema_location | ||
self.no_namespace_schema_location = no_namespace_schema_location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.