From 19790803966ee1d8b3121bdced3328d3551a3a03 Mon Sep 17 00:00:00 2001 From: Fuhu Xia Date: Wed, 18 Jan 2023 12:33:35 -0500 Subject: [PATCH 1/2] use python 3.8 in test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eccc5206..1b8d2f58 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v2 with: - python-version: '3.6' + python-version: '3.8' - name: Install requirements run: pip install flake8 pycodestyle - name: Check syntax From 7a737708fa29d6581fa782ddf0224405147f33b4 Mon Sep 17 00:00:00 2001 From: Fuhu Xia Date: Wed, 18 Jan 2023 12:28:34 -0500 Subject: [PATCH 2/2] do not import future in python 3 --- ckanext/archiver/command_celery.py | 5 +++-- ckanext/archiver/tasks.py | 7 ++++++- ckanext/archiver/tests/mock_remote_server.py | 7 ++++++- ckanext/archiver/tests/test_archiver.py | 10 +++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ckanext/archiver/command_celery.py b/ckanext/archiver/command_celery.py index 66b3f32e..3893d9f2 100644 --- a/ckanext/archiver/command_celery.py +++ b/ckanext/archiver/command_celery.py @@ -1,5 +1,4 @@ from __future__ import print_function -from future import standard_library import sys import os @@ -9,7 +8,9 @@ from ckan.lib.cli import CkanCommand -standard_library.install_aliases() # noqa +if sys.version_info.major < 3: + from future import standard_library + standard_library.install_aliases() # noqa class CeleryCmd(CkanCommand): diff --git a/ckanext/archiver/tasks.py b/ckanext/archiver/tasks.py index 06a1758c..434ce5c8 100644 --- a/ckanext/archiver/tasks.py +++ b/ckanext/archiver/tasks.py @@ -1,6 +1,7 @@ from __future__ import absolute_import from builtins import str import os +import sys import hashlib import http.client import requests @@ -14,7 +15,11 @@ from time import sleep from requests.packages import urllib3 -from future.moves.urllib.parse import urlparse, urljoin, quote, urlunparse + +if sys.version_info.major < 3: + from future.moves.urllib.parse import urlparse, urljoin, quote, urlunparse +else: + from urllib.parse import urlparse, urljoin, quote, urlunparse from ckan.common import _ from ckan.lib import uploader diff --git a/ckanext/archiver/tests/mock_remote_server.py b/ckanext/archiver/tests/mock_remote_server.py index 0355907d..a0e04d3e 100644 --- a/ckanext/archiver/tests/mock_remote_server.py +++ b/ckanext/archiver/tests/mock_remote_server.py @@ -9,11 +9,16 @@ from threading import Thread from time import sleep from wsgiref.simple_server import make_server -from future.moves.urllib.request import urlopen import socket import os +import sys from functools import reduce +if sys.version_info.major < 3: + from future.moves.urllib.request import urlopen +else: + from urllib.request import urlopen + class MockHTTPServer(object): """ diff --git a/ckanext/archiver/tests/test_archiver.py b/ckanext/archiver/tests/test_archiver.py index 731f9639..9e2963bb 100644 --- a/ckanext/archiver/tests/test_archiver.py +++ b/ckanext/archiver/tests/test_archiver.py @@ -4,11 +4,15 @@ import shutil import tempfile import json - -from future.moves.urllib.parse import quote_plus -from ckan.plugins.toolkit import config +import sys import pytest +if sys.version_info.major < 3: + from future.moves.urllib.parse import quote_plus +else: + from urllib.parse import quote_plus + +from ckan.plugins.toolkit import config from ckan import model from ckan import plugins from ckan.logic import get_action