-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmrz_test_quality.py
More file actions
106 lines (88 loc) · 3.89 KB
/
mrz_test_quality.py
File metadata and controls
106 lines (88 loc) · 3.89 KB
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
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
# coding: utf-8
"""
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List
from regula.documentreader.webclient.gen.models.check_result import CheckResult
from regula.documentreader.webclient.gen.models.string_item import StringItem
from typing import Optional, Set
from typing_extensions import Self
class MRZTestQuality(BaseModel):
"""
MRZTestQuality
""" # noqa: E501
check_sums: CheckResult = Field(alias="CHECK_SUMS")
contrast_print: CheckResult = Field(alias="CONTRAST_PRINT")
doc_format: StrictInt = Field(alias="DOC_FORMAT")
mrz_format: StrictInt = Field(alias="MRZ_FORMAT")
print_position: CheckResult = Field(alias="PRINT_POSITION")
stain_mrz: CheckResult = Field(alias="STAIN_MRZ")
symbols_param: CheckResult = Field(alias="SYMBOLS_PARAM")
str_count: StrictInt = Field(alias="StrCount")
strings: List[StringItem] = Field(alias="Strings")
textual_filling: CheckResult = Field(alias="TEXTUAL_FILLING")
__properties: ClassVar[List[str]] = ["CHECK_SUMS", "CONTRAST_PRINT", "DOC_FORMAT", "MRZ_FORMAT", "PRINT_POSITION", "STAIN_MRZ", "SYMBOLS_PARAM", "StrCount", "Strings", "TEXTUAL_FILLING"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of MRZTestQuality from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of each item in strings (list)
_items = []
if self.strings:
for _item_strings in self.strings:
if _item_strings:
_items.append(_item_strings.to_dict())
_dict['Strings'] = _items
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of MRZTestQuality from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"CHECK_SUMS": obj.get("CHECK_SUMS"),
"CONTRAST_PRINT": obj.get("CONTRAST_PRINT"),
"DOC_FORMAT": obj.get("DOC_FORMAT"),
"MRZ_FORMAT": obj.get("MRZ_FORMAT"),
"PRINT_POSITION": obj.get("PRINT_POSITION"),
"STAIN_MRZ": obj.get("STAIN_MRZ"),
"SYMBOLS_PARAM": obj.get("SYMBOLS_PARAM"),
"StrCount": obj.get("StrCount"),
"Strings": [StringItem.from_dict(_item) for _item in obj.get("Strings", []) if StringItem.from_dict(_item) is not None],
"TEXTUAL_FILLING": obj.get("TEXTUAL_FILLING")
})
return _obj