File tree Expand file tree Collapse file tree 3 files changed +23
-28
lines changed
Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Original file line number Diff line number Diff line change 1+ """Image utility functions shared across VWS modules."""
2+
3+ import io
4+ from typing import BinaryIO
5+
6+ from beartype import beartype
7+
8+ ImageType = io .BytesIO | BinaryIO
9+
10+
11+ @beartype
12+ def get_image_data (image : ImageType ) -> bytes :
13+ """Get the data of an image file."""
14+ original_tell = image .tell ()
15+ image .seek (0 )
16+ image_data = image .read ()
17+ image .seek (original_tell )
18+ return image_data
Original file line number Diff line number Diff line change 11"""Tools for interacting with the Vuforia Cloud Recognition Web APIs."""
22
33import datetime
4- import io
54import json
65from http import HTTPMethod , HTTPStatus
7- from typing import Any , BinaryIO
6+ from typing import Any
87
98from beartype import BeartypeConf , beartype
109from urllib3 .filepost import encode_multipart_formdata
1110from vws_auth_tools import authorization_header , rfc_1123_date
1211
12+ from vws ._image_utils import ImageType as _ImageType
13+ from vws ._image_utils import get_image_data as _get_image_data
1314from vws .exceptions .cloud_reco_exceptions import (
1415 AuthenticationFailureError ,
1516 BadImageError ,
2526from vws .reports import QueryResult , TargetData
2627from vws .transports import RequestsTransport , Transport
2728
28- _ImageType = io .BytesIO | BinaryIO
29-
30-
31- @beartype
32- def _get_image_data (image : _ImageType ) -> bytes :
33- """Get the data of an image file."""
34- original_tell = image .tell ()
35- image .seek (0 )
36- image_data = image .read ()
37- image .seek (original_tell )
38- return image_data
39-
4029
4130@beartype (conf = BeartypeConf (is_pep484_tower = True ))
4231class CloudRecoService :
Original file line number Diff line number Diff line change 11"""Tools for interacting with Vuforia APIs."""
22
33import base64
4- import io
54import json
65import time
76from datetime import date
87from http import HTTPMethod , HTTPStatus
9- from typing import BinaryIO
108
119from beartype import BeartypeConf , beartype
1210
11+ from vws ._image_utils import ImageType as _ImageType
12+ from vws ._image_utils import get_image_data as _get_image_data
1313from vws ._vws_request import target_api_request
1414from vws .exceptions .custom_exceptions import (
1515 ServerError ,
4545from vws .response import Response
4646from vws .transports import RequestsTransport , Transport
4747
48- _ImageType = io .BytesIO | BinaryIO
49-
50-
51- @beartype
52- def _get_image_data (image : _ImageType ) -> bytes :
53- """Get the data of an image file."""
54- original_tell = image .tell ()
55- image .seek (0 )
56- image_data = image .read ()
57- image .seek (original_tell )
58- return image_data
59-
6048
6149@beartype (conf = BeartypeConf (is_pep484_tower = True ))
6250class VWS :
You can’t perform that action at this time.
0 commit comments