Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions idutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (C) 2018 Alan Rubin.
# Copyright (C) 2019 Inria.
# Copyright (C) 2022 University of Münster.
# Copyright (C) 2025 Graz University of Technology.
#
# IDUtils is free software; you can redistribute it and/or modify
# it under the terms of the Revised BSD License; see LICENSE file for
Expand All @@ -16,33 +17,11 @@

"""Small library for persistent identifiers used in scholarly communication."""

import importlib
import pkgutil
from warnings import warn

warn(
"Implicit imports (e.g., 'import idutils; idutils.function;') might be removed in the next major version. Please use explicit imports (e.g., 'from idutils import function;') instead.",
DeprecationWarning,
stacklevel=2,
)
from .detectors import *
from .normalizers import *
from .proxies import *
from .schemes import *
from .utils import *
from .validators import *

__version__ = "1.5.0"


def import_attributes():
"""For backwards compatibility! Import everything for `idutils.__func__` and `from idutils import __func__` to work."""
package_name = __name__

importlib.import_module
for _, file_name, _ in pkgutil.walk_packages(__path__):
module = importlib.import_module(f".{file_name}", package_name)

for attribute_name in dir(module):
attribute = getattr(module, attribute_name)

# Make sure it's not private or built-in
if not attribute_name.startswith("_"):
globals()[attribute_name] = attribute


import_attributes()
34 changes: 34 additions & 0 deletions tests/test_raise_deprecation_warning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
#
# This file is part of IDUtils
# Copyright (C) 2015-2022 CERN.
# Copyright (C) 2015-2018 Alan Rubin.
# Copyright (C) 2025 Will Riley.
# Copyright (C) 2025 Graz University of Technology.
#
# IDUtils is free software; you can redistribute it and/or modify
# it under the terms of the Revised BSD License; see LICENSE file for
# more details.
#
# In applying this license, CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

"""Persistent identifier utilities tests."""


# om idutils import is_wikidata


def test_kk():
"""Test kk."""
from idutils import is_wikidata

assert is_wikidata("wikidata:Q303")


def test_namespace_import():
"""Test wikidata validation."""
import idutils

assert idutils.is_wikidata("wikidata:Q303")