From 629ea6a39449729e5e014a3aee7506153d1e6450 Mon Sep 17 00:00:00 2001 From: Zacharias Zacharodimos Date: Tue, 15 Oct 2024 10:19:02 +0200 Subject: [PATCH] release: v1.3.0 --- CHANGES.rst | 4 +++- idutils/__init__.py | 31 +++++++++++++++---------------- idutils/validators.py | 2 +- tests/test_idutils.py | 2 -- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 280924f..b57008c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -15,9 +15,11 @@ Changes ======= -Version 2.0.0 (2024-09-30) +Version 1.3.0 (2024-10-15) - Restructure module to be configurable and readable. +- Adds a new entrypoint to register new custom schemes +- Adds deprecations for direct imports of schemes Version 1.2.1 (2023-03-02) diff --git a/idutils/__init__.py b/idutils/__init__.py index 9df5ae2..6d48e58 100644 --- a/idutils/__init__.py +++ b/idutils/__init__.py @@ -16,17 +16,16 @@ """Small library for persistent identifiers used in scholarly communication. - Setting up custom schemes ------------------------- +------------------------- In order to define your own custom schemes you can use the following entrypoint to register them .. code-block:: python -[options.entry_points] -idutils.custom_schemes = - my_new_scheme = my_module.get_scheme_config_func + [options.entry_points] + idutils.custom_schemes = + my_new_scheme = my_module.get_scheme_config_func The entry point ``'my_new_scheme = my_module.get_scheme_config_func'`` defines an entry point named ``my_new_scheme`` pointing to the function ``my_module.get_scheme_config_func`` @@ -36,17 +35,17 @@ .. code-block:: python -def get_scheme_config_func(): - return { - # See examples in `idutils.validators` file. - "validator": lambda value: True else False, - # Used in `idutils.normalizers.normalize_pid` function. - "normalizer": lambda value: normalized_value, - # See examples in `idutils.detectors.IDUTILS_SCHEME_FILTER` config. - "filter": ["list_of_schemes_to_filter_out"], - # Used in `idutils.normalizers.to_url` function. - "url_generator": lambda scheme, normalized_pid: "normalized_url", - } + def get_scheme_config_func(): + return { + # See examples in `idutils.validators` file. + "validator": lambda value: True else False, + # Used in `idutils.normalizers.normalize_pid` function. + "normalizer": lambda value: normalized_value, + # See examples in `idutils.detectors.IDUTILS_SCHEME_FILTER` config. + "filter": ["list_of_schemes_to_filter_out"], + # Used in `idutils.normalizers.to_url` function. + "url_generator": lambda scheme, normalized_pid: "normalized_url", + } Each key is optional and if not provided a default value is defined in `idutils.ext._set_default_custom_scheme_config()` function. diff --git a/idutils/validators.py b/idutils/validators.py index 27f4ec0..364279f 100644 --- a/idutils/validators.py +++ b/idutils/validators.py @@ -14,7 +14,7 @@ """Utility file containing ID validators.""" -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from .utils import * from .utils import _convert_x_to_10 diff --git a/tests/test_idutils.py b/tests/test_idutils.py index 1edf89e..e193832 100644 --- a/tests/test_idutils.py +++ b/tests/test_idutils.py @@ -14,8 +14,6 @@ """Persistent identifier utilities tests.""" -from __future__ import absolute_import, print_function - import pytest import idutils