From e15b44770cc460843421c590415142e02eb6e8c4 Mon Sep 17 00:00:00 2001 From: Pablo Panero Date: Mon, 31 Jan 2022 11:00:50 +0100 Subject: [PATCH] global: remove python2 support --- invenio_oaiserver/__init__.py | 4 +--- invenio_oaiserver/errors.py | 4 +--- invenio_oaiserver/ext.py | 5 +---- invenio_oaiserver/fetchers.py | 4 +--- invenio_oaiserver/minters.py | 7 +------ invenio_oaiserver/models.py | 4 +--- invenio_oaiserver/percolator.py | 6 +----- invenio_oaiserver/provider.py | 4 +--- invenio_oaiserver/proxies.py | 4 +--- invenio_oaiserver/query.py | 5 ++--- invenio_oaiserver/receivers.py | 4 +--- invenio_oaiserver/utils.py | 12 ++---------- invenio_oaiserver/verbs.py | 4 +--- invenio_oaiserver/version.py | 4 +--- invenio_oaiserver/views/server.py | 2 -- setup.py | 8 ++++---- tests/conftest.py | 2 -- tests/helpers.py | 3 --- tests/test_admin.py | 2 -- tests/test_app.py | 2 -- tests/test_invenio_oaiserver.py | 2 -- tests/test_verbs.py | 2 -- 22 files changed, 20 insertions(+), 74 deletions(-) diff --git a/invenio_oaiserver/__init__.py b/invenio_oaiserver/__init__.py index fc4e99e..897b907 100644 --- a/invenio_oaiserver/__init__.py +++ b/invenio_oaiserver/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# Copyright (C) 2015-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -182,8 +182,6 @@ (GPLv3 licensed). """ -from __future__ import absolute_import, print_function - from .ext import InvenioOAIServer from .proxies import current_oaiserver from .version import __version__ diff --git a/invenio_oaiserver/errors.py b/invenio_oaiserver/errors.py index 9de87f2..f13cb8d 100644 --- a/invenio_oaiserver/errors.py +++ b/invenio_oaiserver/errors.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # Copyright (C) 2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,8 +9,6 @@ """Error.""" -from __future__ import absolute_import, print_function - class OAIBadMetadataFormatError(Exception): """Metadata format required doesn't exist.""" diff --git a/invenio_oaiserver/ext.py b/invenio_oaiserver/ext.py index 3a49f30..b5d7603 100644 --- a/invenio_oaiserver/ext.py +++ b/invenio_oaiserver/ext.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# Copyright (C) 2015-2022 CERN. # Copyright (C) 2021-2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,10 +9,7 @@ """Invenio-OAIServer extension implementation.""" -from __future__ import absolute_import, print_function - from invenio_base.utils import obj_or_import_string -from invenio_records import signals as records_signals from sqlalchemy.event import contains, listen, remove from . import config diff --git a/invenio_oaiserver/fetchers.py b/invenio_oaiserver/fetchers.py index f6e598f..361e62c 100644 --- a/invenio_oaiserver/fetchers.py +++ b/invenio_oaiserver/fetchers.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # Copyright (C) 2021 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,8 +9,6 @@ """Persistent identifier fetchers.""" -from __future__ import absolute_import, print_function - from elasticsearch_dsl.query import Q from invenio_pidstore.errors import PersistentIdentifierError from invenio_pidstore.fetchers import FetchedPID diff --git a/invenio_oaiserver/minters.py b/invenio_oaiserver/minters.py index a01dc92..a005541 100644 --- a/invenio_oaiserver/minters.py +++ b/invenio_oaiserver/minters.py @@ -1,22 +1,17 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Persistent identifier minters.""" -from __future__ import absolute_import, print_function - -from datetime import datetime - from flask import current_app from invenio_pidstore import current_pidstore from .provider import OAIIDProvider -from .utils import datetime_to_datestamp def oaiid_minter(record_uuid, data): diff --git a/invenio_oaiserver/models.py b/invenio_oaiserver/models.py index 6c25e3b..7361d9b 100644 --- a/invenio_oaiserver/models.py +++ b/invenio_oaiserver/models.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# Copyright (C) 2015-2022 CERN. # Copyright (C) 2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -11,12 +11,10 @@ from flask_babelex import lazy_gettext as _ from invenio_db import db -from sqlalchemy.event import listen from sqlalchemy.orm import validates from sqlalchemy_utils import Timestamp from .errors import OAISetSpecUpdateError -from .proxies import current_oaiserver class OAISet(db.Model, Timestamp): diff --git a/invenio_oaiserver/percolator.py b/invenio_oaiserver/percolator.py index 8900b71..a46408c 100644 --- a/invenio_oaiserver/percolator.py +++ b/invenio_oaiserver/percolator.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2017-2018 CERN. +# Copyright (C) 2017-2022 CERN. # Copyright (C) 2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,8 +9,6 @@ """Percolator.""" -from __future__ import absolute_import, print_function - import json from elasticsearch import VERSION as ES_VERSION @@ -23,8 +21,6 @@ from invenio_oaiserver.query import query_string_parser -from .proxies import current_oaiserver - def _build_percolator_index_name(index): """Build percolator index name.""" diff --git a/invenio_oaiserver/provider.py b/invenio_oaiserver/provider.py index b5f0223..b18373a 100644 --- a/invenio_oaiserver/provider.py +++ b/invenio_oaiserver/provider.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# Copyright (C) 2015-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """OAI-PMH ID provider.""" -from __future__ import absolute_import, print_function - from invenio_pidstore.models import PIDStatus from invenio_pidstore.providers.base import BaseProvider diff --git a/invenio_oaiserver/proxies.py b/invenio_oaiserver/proxies.py index 134ee65..eb4ce66 100644 --- a/invenio_oaiserver/proxies.py +++ b/invenio_oaiserver/proxies.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Helper proxy to the state object.""" -from __future__ import absolute_import, print_function - from flask import current_app from werkzeug.local import LocalProxy diff --git a/invenio_oaiserver/query.py b/invenio_oaiserver/query.py index 45766d4..dca8cdc 100644 --- a/invenio_oaiserver/query.py +++ b/invenio_oaiserver/query.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # Copyright (C) 2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,7 +9,6 @@ """Query parser.""" -import six from elasticsearch import VERSION as ES_VERSION from elasticsearch_dsl import Q from flask import current_app @@ -25,7 +24,7 @@ def query_string_parser(search_pattern): """Elasticsearch query string parser.""" if not hasattr(current_oaiserver, 'query_parser'): query_parser = current_app.config['OAISERVER_QUERY_PARSER'] - if isinstance(query_parser, six.string_types): + if isinstance(query_parser, str): query_parser = import_string(query_parser) current_oaiserver.query_parser = query_parser query_parser_fields = ( diff --git a/invenio_oaiserver/receivers.py b/invenio_oaiserver/receivers.py index 7de3cca..8c74cb1 100644 --- a/invenio_oaiserver/receivers.py +++ b/invenio_oaiserver/receivers.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. +# Copyright (C) 2016-2022 CERN. # Copyright (C) 2022 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it @@ -9,8 +9,6 @@ """Record field function.""" -from __future__ import absolute_import, print_function - from .percolator import _delete_percolator, _new_percolator diff --git a/invenio_oaiserver/utils.py b/invenio_oaiserver/utils.py index 495ec5c..153c625 100644 --- a/invenio_oaiserver/utils.py +++ b/invenio_oaiserver/utils.py @@ -1,18 +1,16 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. +# Copyright (C) 2015-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Utilities.""" -from __future__ import absolute_import, print_function - import re from datetime import datetime -from functools import partial +from functools import lru_cache, partial from flask import current_app from invenio_base.utils import obj_or_import_string @@ -22,12 +20,6 @@ from .proxies import current_oaiserver -try: - from functools import lru_cache -except ImportError: # pragma: no cover - from functools32 import lru_cache - - ns = { None: 'http://datacite.org/schema/kernel-4', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', diff --git a/invenio_oaiserver/verbs.py b/invenio_oaiserver/verbs.py index 4eed982..f6d361a 100644 --- a/invenio_oaiserver/verbs.py +++ b/invenio_oaiserver/verbs.py @@ -10,11 +10,9 @@ """OAI-PMH verbs.""" -from __future__ import absolute_import - from flask import current_app, request from invenio_rest.serializer import BaseSchema -from marshmallow import ValidationError, fields, utils, validates_schema +from marshmallow import ValidationError, fields, validates_schema from marshmallow.fields import DateTime as _DateTime from marshmallow.utils import isoformat diff --git a/invenio_oaiserver/version.py b/invenio_oaiserver/version.py index a75ec72..3ab7e6d 100644 --- a/invenio_oaiserver/version.py +++ b/invenio_oaiserver/version.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2020 CERN. +# Copyright (C) 2015-2022 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -12,6 +12,4 @@ and parsed by ``setup.py``. """ -from __future__ import absolute_import, print_function - __version__ = '1.3.0' diff --git a/invenio_oaiserver/views/server.py b/invenio_oaiserver/views/server.py index 0ce0ddb..5cfff87 100644 --- a/invenio_oaiserver/views/server.py +++ b/invenio_oaiserver/views/server.py @@ -9,8 +9,6 @@ """OAI-PMH 2.0 server.""" -from __future__ import absolute_import - from flask import Blueprint, make_response from invenio_pidstore.errors import PIDDoesNotExistError from itsdangerous import BadSignature diff --git a/setup.py b/setup.py index 17024b4..1b7e1a2 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2015-2019 CERN. +# Copyright (C) 2015-2022 CERN. # Copyright (C) 2021 Graz University of Technology. # Copyright (C) 2021 TU Wien. # @@ -148,10 +148,10 @@ 'Programming Language :: Python', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development :: Libraries :: Python Modules', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Development Status :: 5 - Production/Stable', ], ) diff --git a/tests/conftest.py b/tests/conftest.py index bd9b276..aa6d0e4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,8 +8,6 @@ """Pytest configuration.""" -from __future__ import absolute_import, print_function - import os import shutil import tempfile diff --git a/tests/helpers.py b/tests/helpers.py index 068bf96..ac6d4db 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -9,8 +9,6 @@ """Utilities for loading test records.""" -from __future__ import absolute_import, print_function - import uuid import mock @@ -21,7 +19,6 @@ from invenio_indexer.api import RecordIndexer from invenio_pidstore.minters import recid_minter from invenio_pidstore.models import PersistentIdentifier -from invenio_records import Record from invenio_records.models import RecordMetadata from invenio_search import current_search, current_search_client diff --git a/tests/test_admin.py b/tests/test_admin.py index 58b5a9e..37e4774 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -8,8 +8,6 @@ """Test admin interface.""" -from __future__ import absolute_import, print_function - from flask import url_for from flask_admin import Admin, menu from invenio_db import db diff --git a/tests/test_app.py b/tests/test_app.py index 761cbaf..7c0392e 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -8,8 +8,6 @@ """Test app.""" -from __future__ import absolute_import - import pytest from flask import Flask diff --git a/tests/test_invenio_oaiserver.py b/tests/test_invenio_oaiserver.py index 618594b..02cfe36 100644 --- a/tests/test_invenio_oaiserver.py +++ b/tests/test_invenio_oaiserver.py @@ -8,8 +8,6 @@ """Module tests.""" -from __future__ import absolute_import, print_function - import socket import pytest diff --git a/tests/test_verbs.py b/tests/test_verbs.py index f11862e..46350e3 100644 --- a/tests/test_verbs.py +++ b/tests/test_verbs.py @@ -10,8 +10,6 @@ """Test OAI verbs.""" -from __future__ import absolute_import - import uuid from copy import deepcopy from datetime import datetime, timedelta