Skip to content

Commit

Permalink
Drop Python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Averin committed Jun 25, 2024
1 parent 37d7609 commit 2b6abde
Show file tree
Hide file tree
Showing 94 changed files with 137 additions and 334 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

[Aspose.BarCode for Cloud](https://products.aspose.cloud/barcode/) is a REST API for Linear, 2D and postal barcode generation and recognition in the cloud. API recognizes and generates barcode images in a variety of formats. Barcode REST API allows to specify barcode image attributes like image width, height, border style and output image format in order to customize the generation process. Developers can also specify the barcode type and text attributes such as text location and font styles in order to suit the application requirements.

This repository contains Aspose.BarCode Cloud SDK for Python source code. This SDK allows you to work with Aspose.BarCode for Cloud REST APIs in your Python 2 or Python 3 applications quickly and easily.
This repository contains Aspose.BarCode Cloud SDK for Python source code. This SDK allows you to work with Aspose.BarCode for Cloud REST APIs in your Python 3 applications quickly and easily.

Supported Python versions:

Expand Down Expand Up @@ -90,7 +90,6 @@ pprint(response)

## Requirements

- six >= 1.10
- urllib3 >= 1.21.1, <2.0

## Licensing
Expand Down
19 changes: 8 additions & 11 deletions aspose_barcode_cloud/api/barcode_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import re # noqa: F401
import warnings # noqa: F401

# python 2 and python 3 compatibility library
import six

from aspose_barcode_cloud.api_client import ApiClient


Expand Down Expand Up @@ -254,7 +251,7 @@ def get_barcode_generate_with_http_info(self, type, text, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method get_barcode_generate" % key)
if val is None:
Expand Down Expand Up @@ -627,7 +624,7 @@ def get_barcode_recognize_with_http_info(self, name, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method get_barcode_recognize" % key)
if val is None:
Expand Down Expand Up @@ -999,7 +996,7 @@ def post_barcode_recognize_from_url_or_content_with_http_info(self, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
Expand Down Expand Up @@ -1175,7 +1172,7 @@ def post_generate_multiple_with_http_info(self, generator_params_list, **kwargs)
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method post_generate_multiple" % key)
if val is None:
Expand Down Expand Up @@ -1483,7 +1480,7 @@ def put_barcode_generate_file_with_http_info(self, name, type, text, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method put_barcode_generate_file" % key)
if val is None:
Expand Down Expand Up @@ -1673,7 +1670,7 @@ def put_barcode_recognize_from_body_with_http_info(self, name, reader_params, **
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'" " to method put_barcode_recognize_from_body" % key
Expand Down Expand Up @@ -1794,7 +1791,7 @@ def put_generate_multiple_with_http_info(self, name, generator_params_list, **kw
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method put_generate_multiple" % key)
if val is None:
Expand Down Expand Up @@ -1906,7 +1903,7 @@ def scan_barcode_with_http_info(self, image_file, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method scan_barcode" % key)
if val is None:
Expand Down
13 changes: 5 additions & 8 deletions aspose_barcode_cloud/api/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import re # noqa: F401
import warnings # noqa: F401

# python 2 and python 3 compatibility library
import six

from aspose_barcode_cloud.api_client import ApiClient


Expand Down Expand Up @@ -93,7 +90,7 @@ def copy_file_with_http_info(self, src_path, dest_path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method copy_file" % key)
if val is None:
Expand Down Expand Up @@ -201,7 +198,7 @@ def delete_file_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method delete_file" % key)
if val is None:
Expand Down Expand Up @@ -302,7 +299,7 @@ def download_file_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method download_file" % key)
if val is None:
Expand Down Expand Up @@ -429,7 +426,7 @@ def move_file_with_http_info(self, src_path, dest_path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method move_file" % key)
if val is None:
Expand Down Expand Up @@ -538,7 +535,7 @@ def upload_file_with_http_info(self, path, file, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method upload_file" % key)
if val is None:
Expand Down
13 changes: 5 additions & 8 deletions aspose_barcode_cloud/api/folder_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import re # noqa: F401
import warnings # noqa: F401

# python 2 and python 3 compatibility library
import six

from aspose_barcode_cloud.api_client import ApiClient


Expand Down Expand Up @@ -75,7 +72,7 @@ def copy_folder_with_http_info(self, src_path, dest_path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method copy_folder" % key)
if val is None:
Expand Down Expand Up @@ -180,7 +177,7 @@ def create_folder_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method create_folder" % key)
if val is None:
Expand Down Expand Up @@ -279,7 +276,7 @@ def delete_folder_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method delete_folder" % key)
if val is None:
Expand Down Expand Up @@ -379,7 +376,7 @@ def get_files_list_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method get_files_list" % key)
if val is None:
Expand Down Expand Up @@ -486,7 +483,7 @@ def move_folder_with_http_info(self, src_path, dest_path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method move_folder" % key)
if val is None:
Expand Down
11 changes: 4 additions & 7 deletions aspose_barcode_cloud/api/storage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import re # noqa: F401
import warnings # noqa: F401

# python 2 and python 3 compatibility library
import six

from aspose_barcode_cloud.api_client import ApiClient


Expand Down Expand Up @@ -64,7 +61,7 @@ def get_disc_usage_with_http_info(self, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method get_disc_usage" % key)
if val is None:
Expand Down Expand Up @@ -157,7 +154,7 @@ def get_file_versions_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method get_file_versions" % key)
if val is None:
Expand Down Expand Up @@ -256,7 +253,7 @@ def object_exists_with_http_info(self, path, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method object_exists" % key)
if val is None:
Expand Down Expand Up @@ -355,7 +352,7 @@ def storage_exists_with_http_info(self, storage_name, **kwargs):
all_params.add("_request_timeout")

params = locals()
for key, val in six.iteritems(params["kwargs"]):
for key, val in params["kwargs"].items():
if key not in all_params:
raise TypeError("Got an unexpected keyword argument '%s'" " to method storage_exists" % key)
if val is None:
Expand Down
37 changes: 16 additions & 21 deletions aspose_barcode_cloud/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@
import io
import json
import mimetypes
import pathlib
from collections import namedtuple
from multiprocessing.pool import ThreadPool
import os
import re
import tempfile

# python 2 and python 3 compatibility library
import six
from six.moves.urllib.parse import quote

if not six.PY2:
import pathlib
import urllib.parse

from aspose_barcode_cloud.configuration import Configuration
import aspose_barcode_cloud.models
Expand Down Expand Up @@ -45,10 +40,10 @@ class ApiClient(object):
to the API
"""

PRIMITIVE_TYPES = (float, bool, bytes, bytearray, six.text_type) + six.integer_types
PRIMITIVE_TYPES = (int, float, str, bool, bytes, bytearray)
NATIVE_TYPES_MAPPING = {
"int": int,
"long": int if six.PY3 else long, # noqa: F821
"long": int,
"float": float,
"str": str,
"bool": bool,
Expand Down Expand Up @@ -134,7 +129,9 @@ def __call_api(
path_params = self.parameters_to_tuples(path_params, collection_formats)
for k, v in path_params:
# specified safe chars, encode everything
resource_path = resource_path.replace("{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param))
resource_path = resource_path.replace(
"{%s}" % k, urllib.parse.quote(str(v), safe=config.safe_chars_for_path_param)
)

# query parameters
if query_params:
Expand Down Expand Up @@ -219,11 +216,11 @@ def sanitize_for_serialization(self, obj):
# model definition for request.
obj_dict = {
obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.swagger_types)
for attr in obj.swagger_types
if getattr(obj, attr) is not None
}

return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)}
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}

def deserialize(self, response, response_type):
"""Deserializes response into an object.
Expand Down Expand Up @@ -265,7 +262,7 @@ def __deserialize(self, data, klass):

if klass.startswith("dict("):
sub_kls = re.match(r"dict\(([^,]*), (.*)\)", klass).group(2)
return {k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data)}
return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}

# convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
Expand Down Expand Up @@ -467,7 +464,7 @@ def parameters_to_tuples(self, params, collection_formats):
new_params = []
if collection_formats is None:
collection_formats = {}
for k, v in six.iteritems(params) if isinstance(params, dict) else params:
for k, v in params.items() if isinstance(params, dict) else params:
if k in collection_formats:
collection_format = collection_formats[k]
if collection_format == "multi":
Expand All @@ -489,22 +486,20 @@ def parameters_to_tuples(self, params, collection_formats):
def prepare_one_file(self, file_data):
# type: (Union[bytes, str, file, pathlib.Path, io.BytesIO]) -> FileFieldData # noqa: F821

if isinstance(file_data, str) or (not six.PY2 and isinstance(file_data, pathlib.PurePath)):
if isinstance(file_data, str) or isinstance(file_data, pathlib.PurePath):
with open(file_data, "rb") as f:
fname = os.path.basename(f.name)
file_bytes = f.read()
mime_type = mimetypes.guess_type(fname)[0] or "application/octet-stream"
return FileFieldData(fname, file_bytes, mime_type)

# Python 2 has no difference between bytes and str
# Use bytearray in Python 2 to make a difference with str
if isinstance(file_data, bytes) or isinstance(file_data, bytearray):
return FileFieldData("data.bin", file_data, "application/octet-stream")

if isinstance(file_data, io.BytesIO):
return FileFieldData("data.bin", file_data.read(), "application/octet-stream")

if isinstance(file_data, io.BufferedReader) or (six.PY2 and isinstance(file_data, file)): # noqa: F821
if isinstance(file_data, io.BufferedReader):
return FileFieldData(os.path.basename(file_data.name), file_data.read(), "application/octet-stream")

raise ApiException(reason="Unknown type {type_name} for file parameter".format(type_name=type(file_data)))
Expand All @@ -519,7 +514,7 @@ def prepare_post_parameters(self, post_params=None, files=None):
params = post_params or []

if files:
for field_name, data in six.iteritems(files):
for field_name, data in files.items():
if not data:
continue
file_names = data if type(data) is list else [data]
Expand Down Expand Up @@ -616,7 +611,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return six.text_type(data)
return str(data)
except TypeError:
return data

Expand Down Expand Up @@ -675,7 +670,7 @@ def __deserialize_model(self, data, klass):

kwargs = {}
if klass.swagger_types is not None:
for attr, attr_type in six.iteritems(klass.swagger_types):
for attr, attr_type in klass.swagger_types.items():
key = klass.attribute_map[attr]
# Convert from PascalCase to camelCase
# Because server uses camelCase JSON
Expand Down
Loading

0 comments on commit 2b6abde

Please sign in to comment.