-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: add class based registry to extend idutils schemes
- Loading branch information
Showing
9 changed files
with
162 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of IDUtils | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# 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. | ||
|
||
"""Functions for detecting the persistent identifier.""" | ||
|
||
from . import validators | ||
|
||
IDUTILS_PID_SCHEMES_CONFIG = [ | ||
("doi", validators.is_doi), | ||
("ark", validators.is_ark), | ||
("handle", validators.is_handle), | ||
("purl", validators.is_purl), | ||
("lsid", validators.is_lsid), | ||
("urn", validators.is_urn), | ||
("ads", validators.is_ads), | ||
("arxiv", validators.is_arxiv), | ||
("ascl", validators.is_ascl), | ||
("hal", validators.is_hal), | ||
("pmcid", validators.is_pmcid), | ||
("isbn", validators.is_isbn), | ||
("issn", validators.is_issn), | ||
("orcid", validators.is_orcid), | ||
("isni", validators.is_isni), | ||
("ean13", validators.is_ean13), | ||
("ean8", validators.is_ean8), | ||
("istc", validators.is_istc), | ||
("gnd", validators.is_gnd), | ||
("ror", validators.is_ror), | ||
("pmid", validators.is_pmid), | ||
("url", validators.is_url), | ||
("sra", validators.is_sra), | ||
("bioproject", validators.is_bioproject), | ||
("biosample", validators.is_biosample), | ||
("ensembl", validators.is_ensembl), | ||
("uniprot", validators.is_uniprot), | ||
("refseq", validators.is_refseq), | ||
("genome", validators.is_genome), | ||
("geo", validators.is_geo), | ||
("arrayexpress_array", validators.is_arrayexpress_array), | ||
("arrayexpress_experiment", validators.is_arrayexpress_experiment), | ||
("swh", validators.is_swh), | ||
("viaf", validators.is_viaf), | ||
] | ||
"""Definition of scheme name and associated test function. | ||
Order of list is important, as identifier scheme detection will test in the | ||
order given by this list.""" | ||
|
||
|
||
IDUTILS_SCHEME_FILTER_CONFIG = [ | ||
( | ||
"url", | ||
# None these can have URLs, in which case we exclude them | ||
["isbn", "istc", "urn", "lsid", "issn", "ean8", "viaf"], | ||
), | ||
("ean8", ["gnd", "pmid", "viaf"]), | ||
("ean13", ["gnd", "pmid"]), | ||
("isbn", ["gnd", "pmid"]), | ||
("orcid", ["gnd", "pmid"]), | ||
("isni", ["gnd", "pmid"]), | ||
( | ||
"issn", | ||
[ | ||
"gnd", | ||
"viaf", | ||
], | ||
), | ||
("pmid", ["viaf"]), | ||
] | ||
"""(present_scheme, [list of schemes to remove if present_scheme found]).""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of IDUtils | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# 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.""" | ||
|
||
import pytest | ||
|
||
from idutils.proxies import custom_schemes_registry | ||
|
||
|
||
def test_custom_registry_singleton(entry_points): | ||
"""Test that the registry is instantiated only once.""" | ||
instance1 = custom_schemes_registry() | ||
|
||
instance2 = custom_schemes_registry() | ||
|
||
assert instance1 is instance2 |
Oops, something went wrong.