Skip to content

Commit f04591f

Browse files
committed
Make lib compatible with python 3.5+
1 parent fd32863 commit f04591f

File tree

9 files changed

+28
-26
lines changed

9 files changed

+28
-26
lines changed

Pipfile.lock

100755100644
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ name = "test-pypi"
1212
"regula.documentreader.webclient" = {editable = true,path = "./.."}
1313

1414
[requires]
15-
python_version = "3.8"
15+
python_version = "3.5"

example/Pipfile.lock

100755100644
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
response_images = response.images
4040

41-
print(f"""
41+
print("""
4242
---------------------------------------------------------------------------
4343
Document Overall Status: {doc_overall_status}
4444
Document Number Visual: {doc_number_visual}
@@ -47,4 +47,8 @@
4747
Validity Of Document Number MRZ: {doc_number_mrz_validity}
4848
MRZ-Visual values comparison: {doc_number_mrz_visual_matching}
4949
---------------------------------------------------------------------------
50-
""")
50+
""".format(
51+
doc_overall_status=doc_overall_status, doc_number_visual=doc_number_visual,
52+
doc_number_mrz=doc_number_mrz, doc_number_visual_validity=doc_number_mrz_validity,
53+
doc_number_mrz_validity=doc_number_mrz_validity, doc_number_mrz_visual_matching=doc_number_mrz_visual_matching,
54+
))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from regula.documentreader.webclient.ext.api.document_reader_api import DocumentReaderApi
1+
from regula.documentreader.webclient.ext.api.document_reader_api import DocumentReaderApi

regula/documentreader/webclient/ext/api/document_reader_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class DocumentReaderApi(DefaultApi):
8-
__license: str
98

109
def __init__(self, host=None, debug=False, verify_ssl=False, api_client=None):
1110
if api_client:
@@ -16,6 +15,7 @@ def __init__(self, host=None, debug=False, verify_ssl=False, api_client=None):
1615
configuration.verify_ssl = verify_ssl
1716

1817
super().__init__(ApiClient(configuration=configuration))
18+
self.__license = None
1919

2020
def __enter__(self):
2121
return self
@@ -24,11 +24,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
2424
self.api_client.close()
2525

2626
@property
27-
def license(self):
27+
def license(self) -> str:
2828
return self.__license
2929

3030
@license.setter
31-
def license(self, value):
31+
def license(self, value: str):
3232
self.__license = value
3333

3434
def process(self, process_request: ProcessRequest) -> RecognitionResponse:

regula/documentreader/webclient/ext/models/recognition_response.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import uuid
21
from typing import Optional
32

43
from regula.documentreader.webclient.ext.models.text import Text
4+
from regula.documentreader.webclient.gen import ResultItem
55
from regula.documentreader.webclient.gen.models.images import Images
66
from regula.documentreader.webclient.gen.models.process_response import ProcessResponse
77
from regula.documentreader.webclient.gen.models.result import Result
88
from regula.documentreader.webclient.gen.models.status import Status
99

1010

1111
class RecognitionResponse:
12-
__process_response: ProcessResponse
1312

1413
def __init__(self, process_response: ProcessResponse):
1514
self.__process_response = process_response
@@ -18,8 +17,7 @@ def __init__(self, process_response: ProcessResponse):
1817
def text(self) -> Optional[Text]:
1918
result = self.result_by_type(Result.TEXT)
2019
if result:
21-
i = result.text
22-
return Text(i)
20+
return Text(result.text)
2321
return None
2422

2523
@property
@@ -36,7 +34,7 @@ def images(self) -> Optional[Images]:
3634
return result.images
3735
return None
3836

39-
def result_by_type(self, result_type):
37+
def result_by_type(self, result_type) -> Optional[ResultItem]:
4038
for i in self.__process_response.container_list.list:
4139
if i.result_type == result_type:
4240
return i

regula/documentreader/webclient/ext/models/text.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55

66

77
class Text:
8-
__payload: GenText
98

10-
def __init__(self, payload):
9+
def __init__(self, payload: GenText):
1110
self.__payload = payload
1211

13-
def get_field(self, field_type, lcid=0) -> Optional[TextField]:
12+
def get_field(self, field_type: int, lcid=0) -> Optional[TextField]:
1413
for i in self.__payload.field_list:
1514
if i.field_type == field_type and i.lcid == lcid:
1615
return TextField(i)
1716
return None
1817

19-
def get_field_value(self, field_type, lcid=0):
18+
def get_field_value(self, field_type: int, lcid=0) -> Optional[str]:
2019
field = self.get_field(field_type, lcid)
2120
if field:
2221
return "todo"

regula/documentreader/webclient/ext/models/text_field.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
from typing import Optional
2+
13
from regula.documentreader.webclient.gen.models.check_result import CheckResult
24
from regula.documentreader.webclient.gen.models.text_field import TextField as GenTextField
35

46

57
class TextField:
6-
__payload: GenTextField
78

8-
def __init__(self, payload):
9+
def __init__(self, payload: GenTextField):
910
self.__payload = payload
1011

11-
def get_value(self, source, original=False):
12+
def get_value(self, source: str, original=False) -> Optional[str]:
1213
for i in self.__payload.value_list:
1314
if i.source == source:
1415
if original:
@@ -17,13 +18,13 @@ def get_value(self, source, original=False):
1718
return i.value
1819
return None
1920

20-
def get_validity(self, source):
21+
def get_validity(self, source) -> CheckResult:
2122
for i in self.__payload.validity_list:
2223
if i.source == source:
2324
return i.status
2425
return CheckResult.WAS_NOT_DONE
2526

26-
def get_comparison(self, one, other):
27+
def get_comparison(self, one, other) -> CheckResult:
2728
for i in self.__payload.comparison_list:
2829
a = i.source_left == one and i.source_right == other
2930
b = i.source_right == one and i.source_left == other

0 commit comments

Comments
 (0)