Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 276545d

Browse files
Merge pull request #248 from regulaforensics/fix/42691_
42691 - fix deserialize_to_recognition_response
2 parents b60e98c + 7da20c1 commit 276545d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,22 @@ def process(self, process_request: ProcessRequest) -> RecognitionResponse:
3636

3737
def deserialize_to_recognition_response(self, content: Union[bytes, bytearray, str]) -> RecognitionResponse:
3838
response = self.__to_response_object(content)
39-
response = self.api_client.deserialize(response, ProcessResponse)
40-
return RecognitionResponse(response)
39+
40+
if hasattr(response, 'to_str'):
41+
response_text = response.to_str()
42+
elif hasattr(response, 'data'):
43+
data = response.data
44+
if isinstance(data, (bytes, bytearray)):
45+
response_text = data.decode('utf-8')
46+
else:
47+
response_text = str(data)
48+
else:
49+
response_text = str(content) if not isinstance(content, str) else content
50+
51+
content_type = "application/json"
52+
process_response = self.api_client.deserialize(response_text, "ProcessResponse", content_type)
53+
54+
return RecognitionResponse(process_response)
4155

4256
@staticmethod
4357
def __to_response_object(content: Union[bytes, bytearray, str]):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /