From cd942c3218c7ea8e482d3bcb61d1a1e0e2c83338 Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Tue, 4 Jul 2023 13:44:48 +0300 Subject: [PATCH 1/7] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index de14a34..1e05d78 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,14 @@ user_info = convertapi.user() print(user_info['SecondsLeft']) ``` +### Alternative domain + +Set `base_uri` parameter to use other service domains. Dedicated to the region [domain list](https://www.convertapi.com/doc/servers-location). + +``` +convertapi.base_uri = 'https://eu-v2.convertapi.com/' +``` + ### More examples Find more advanced examples in the [/examples](https://github.com/ConvertAPI/convertapi-python/tree/master/examples) folder. From 7f3d4d3497e5a06bfa34a2a7cc16f954297aeabf Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Tue, 4 Jul 2023 13:51:18 +0300 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e05d78..aef69f2 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ print(user_info['SecondsLeft']) Set `base_uri` parameter to use other service domains. Dedicated to the region [domain list](https://www.convertapi.com/doc/servers-location). -``` +```python convertapi.base_uri = 'https://eu-v2.convertapi.com/' ``` From 7da792dd4cd7b54fd344058ae235584c6152bac1 Mon Sep 17 00:00:00 2001 From: laurynas-baltsoft <38224044+laurynas-baltsoft@users.noreply.github.com> Date: Wed, 19 Jul 2023 20:05:04 +0300 Subject: [PATCH 3/7] Do not test with python 2.7 https://github.com/actions/setup-python/issues/672 --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 277c7eb..166112e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,6 @@ jobs: strategy: matrix: python-version: - - '2.7' - '3.7' - '3.9' name: Python ${{ matrix.python-version }} sample From 9eddbc8d97af25d4ad392a849975178e26035218 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Wed, 19 Jul 2023 20:01:50 +0300 Subject: [PATCH 4/7] Make converter param name case insensitive --- convertapi/task.py | 12 ++++++++++-- tests/test_convertapi.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/convertapi/task.py b/convertapi/task.py index e580456..89ac093 100644 --- a/convertapi/task.py +++ b/convertapi/task.py @@ -21,10 +21,11 @@ def run(self): params = self.__normalize_params() from_format = self.from_format or self.__detect_format() timeout = self.timeout + convertapi.conversion_timeout_delta if self.timeout else None + converter = self.__detect_converter() path = "convert/%s/to/%s" % (from_format, self.to_format) - if 'converter' in params: - path += "/converter/%s" % (params['converter']) + if converter != None: + path += "/converter/%s" % (converter) response = convertapi.client.post(path, params, timeout = timeout) @@ -61,3 +62,10 @@ def __detect_format(self): if 'Files' in self.params: return format_detector.detect(self.params['Files'][0]) + + def __detect_converter(self): + for k, v in self.params.items(): + if k.lower() == 'converter': + return v + + return None diff --git a/tests/test_convertapi.py b/tests/test_convertapi.py index 4453a16..0ccfad9 100644 --- a/tests/test_convertapi.py +++ b/tests/test_convertapi.py @@ -30,7 +30,7 @@ def test_convert_file_no_parallelizm(self): assert result.save_files(tempfile.gettempdir()) def test_convert_file_alternative(self): - result = convertapi.convert('pdf', { 'File': 'examples/files/test.docx', 'converter': 'openoffice' }) + result = convertapi.convert('pdf', { 'File': 'examples/files/test.docx', 'Converter': 'openoffice' }) assert result.save_files(tempfile.gettempdir()) assert result.conversion_cost > 0 From b383f04b645029e22c857d69e9ef763be3cd698c Mon Sep 17 00:00:00 2001 From: laurynas-baltsoft <38224044+laurynas-baltsoft@users.noreply.github.com> Date: Wed, 19 Jul 2023 20:07:25 +0300 Subject: [PATCH 5/7] Remove python 2.7 from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aef69f2..13de2b6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Install from source with: ### Requirements -* Python 2.7+ or Python 3.3+ +* Python 3.3+ ## Usage From 736bb38e5c77c8a7bb14defd461d0fa684eb7087 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Wed, 19 Jul 2023 20:21:57 +0300 Subject: [PATCH 6/7] Handle multiple file params --- convertapi/task.py | 2 +- tests/test_convertapi.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/convertapi/task.py b/convertapi/task.py index 89ac093..af15fc6 100644 --- a/convertapi/task.py +++ b/convertapi/task.py @@ -35,7 +35,7 @@ def __normalize_params(self): params = {} for k, v in self.params.items(): - if k == 'File': + if k != 'StoreFile' and k.endswith('File'): params[k] = file_param.build(v) elif k == 'Files': results = utils.map_in_parallel(file_param.build, v, convertapi.max_parallel_uploads) diff --git a/tests/test_convertapi.py b/tests/test_convertapi.py index 0ccfad9..e66fc49 100644 --- a/tests/test_convertapi.py +++ b/tests/test_convertapi.py @@ -66,6 +66,11 @@ def test_chained_conversion(self): zip_result = convertapi.convert('zip', { 'Files': result.files }) eq_('test.zip', zip_result.file.filename) + def test_compare_files(self): + file = 'examples/files/test.docx' + result = convertapi.convert('compare', { 'File': file, 'CompareFile': file }) + assert result.conversion_cost > 0 + @raises(convertapi.ApiError) def test_api_error(self): convertapi.api_secret = 'TEST' From 0ff444b2e53e3df3825a372b60e6a7ffca2eab0e Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Wed, 19 Jul 2023 20:25:27 +0300 Subject: [PATCH 7/7] Bump version --- convertapi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convertapi/__init__.py b/convertapi/__init__.py index 37ac8e3..094eb44 100644 --- a/convertapi/__init__.py +++ b/convertapi/__init__.py @@ -1,4 +1,4 @@ -__version__ = '1.6.0' +__version__ = '1.7.0' from .exceptions import * from .client import Client