Skip to content

Commit

Permalink
Move 'oai_base' to 'api_endpoint'
Browse files Browse the repository at this point in the history
  • Loading branch information
orviz committed Oct 29, 2024
1 parent 3cfb33f commit c6c0a6b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 34 deletions.
18 changes: 9 additions & 9 deletions api/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EvaluatorBase(ABC):
Digital Object identifier, which can be a generic one (DOI, PID), or an internal (e.g. an
identifier from the repo)
oai_base : str
api_endpoint : str
Open Archives initiative , This is the place in which the API will ask for the metadata
lang : str
Expand All @@ -89,10 +89,10 @@ class EvaluatorBase(ABC):
"""

def __init__(
self, item_id, oai_base=None, lang="en", config=None, name=None, **kwargs
self, item_id, api_endpoint=None, lang="en", config=None, name=None, **kwargs
):
self.item_id = item_id
self.oai_base = oai_base
self.api_endpoint = api_endpoint
self.lang = lang
self.config = config
self.name = name
Expand Down Expand Up @@ -674,7 +674,7 @@ def rda_a1_02m(self):
)
except Exception as e:
logger.error(e)
item_id_http = self.oai_base
item_id_http = self.api_endpoint
points, msg = ut.metadata_human_accessibility(self.metadata, item_id_http)
return (points, [{"message": msg, "points": points}])

Expand Down Expand Up @@ -788,7 +788,7 @@ def rda_a1_03d(self):
msg_list = []
points = 0
try:
landing_url = urllib.parse.urlparse(self.oai_base).netloc
landing_url = urllib.parse.urlparse(self.api_endpoint).netloc
item_id_http = idutils.to_url(
self.item_id,
idutils.detect_identifier_schemes(self.item_id)[0],
Expand Down Expand Up @@ -853,7 +853,7 @@ def rda_a1_04m(self, return_protocol=False):
"""
points = 0

protocol = ut.get_protocol_scheme(self.oai_base)
protocol = ut.get_protocol_scheme(self.api_endpoint)
if protocol in self.terms_access_protocols:
points = 100
msg = "Found a standarised protocol to access the metadata record: " + str(
Expand Down Expand Up @@ -1205,11 +1205,11 @@ def rda_i1_02m(self):
points = 0
msg_list = []
try:
if self.oai_base is not None:
metadata_formats = ut.get_rdf_metadata_format(self.oai_base)
if self.api_endpoint is not None:
metadata_formats = ut.get_rdf_metadata_format(self.api_endpoint)
rdf_metadata = None
for e in metadata_formats:
url = ut.oai_check_record_url(self.oai_base, e, self.item_id)
url = ut.oai_check_record_url(self.api_endpoint, e, self.item_id)
rdf_metadata = ut.oai_get_metadata(url)
if rdf_metadata is not None:
points = 100
Expand Down
8 changes: 5 additions & 3 deletions api/rda.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_evaluator(wrapped_func):
def wrapper(body, **kwargs):
repo = body.get("repo")
item_id = body.get("id", "")
oai_base = body.get("oai_base")
api_endpoint = body.get("api_endpoint")
lang = body.get("lang", "en")
pattern_to_query = body.get("q", "")

Expand All @@ -47,7 +47,7 @@ def wrapper(body, **kwargs):
if pattern_to_query:
try:
ids = plugin.Plugin.get_ids(
oai_base=oai_base, pattern_to_query=pattern_to_query
api_endpoint=api_endpoint, pattern_to_query=pattern_to_query
)
except Exception as e:
logger.error(str(e))
Expand All @@ -64,7 +64,9 @@ def wrapper(body, **kwargs):
result = {}
exit_code = 200
for item_id in ids:
eva = plugin.Plugin(item_id, oai_base, lang, name=repo, config=config_data)
eva = plugin.Plugin(
item_id, api_endpoint, lang, name=repo, config=config_data
)
_result, _exit_code = wrapped_func(body, eva=eva)
logger.debug(
"Raw result returned for indicator ID '%s': %s" % (item_id, _result)
Expand Down
10 changes: 4 additions & 6 deletions plugins/digital_csic/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Plugin(EvaluatorBase):
Digital Object identifier, which can be a generic one (DOI, PID), or an internal (e.g. an
identifier from the repo)
oai_base : str
api_endpoint : str
Open Archives Initiative , This is the place in which the API will ask for the metadata. If you are working with Digital CSIC http://digital.csic.es/dspace-oai/request
lang : Language
Expand All @@ -42,18 +42,16 @@ class Plugin(EvaluatorBase):
def __init__(
self,
item_id,
oai_base="http://digital.csic.es/dspace-oai/request",
api_endpoint="http://digital.csic.es/dspace-oai/request",
lang="en",
config=None,
name="digital_csic",
):
self.config = config
self.name = name
self.lang = lang
self.oai_base = oai_base
self.oai_base = api_endpoint

if oai_base == "":
self.oai_base = None
if ut.get_doi_str(item_id) != "":
self.item_id = ut.get_doi_str(item_id)
self.id_type = "doi"
Expand All @@ -64,7 +62,7 @@ def __init__(
self.item_id = item_id
self.id_type = "internal"

super().__init__(self.item_id, oai_base, self.lang, self.config, self.name)
super().__init__(self.item_id, self.oai_base, self.lang, self.config, self.name)

self.file_list = None
self.metadata = self.get_metadata()
Expand Down
10 changes: 4 additions & 6 deletions plugins/dspace7/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ class DSpace_7(Evaluator):
----------
item_id : str
Digital Object identifier, which can be a generic one (DOI, PID), or an internal (e.g. an identifier from the repo)
oai_base : str
api_endpoint : str
Open Archives initiative , This is the place in which the API will ask for the metadata
lang : Language
"""

def __init__(self, item_id, oai_base=None, lang="en", config=None):
if oai_base == "":
oai_base = None
def __init__(self, item_id, api_endpoint=None, lang="en", config=None):
logger.debug("Call parent")
plugin = "dspace7"
super().__init__(item_id, oai_base, lang, plugin)
super().__init__(item_id, api_endpoint, lang, plugin)
logger.debug("Parent called")
if ut.get_doi_str(item_id) != "":
self.item_id = ut.get_doi_str(item_id)
Expand All @@ -51,7 +49,7 @@ def __init__(self, item_id, oai_base=None, lang="en", config=None):
self.internal_id = self.get_internal_id(item_id)
self.metadata = self.get_item_metadata(self.internal_id)
self.access_protocol = []
self.oai_base = oai_base
self.oai_base = api_endpoint
logging.debug("INTERNAL ID: %s ITEM ID: %s" % (self.internal_id, self.item_id))
if len(self.metadata) > 0:
self.access_protocols = ["http", "REST-API"]
Expand Down
2 changes: 0 additions & 2 deletions plugins/epos/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def __init__(self, *args, **kwargs):
**kwargs,
)

self.api_endpoint = self.oai_base

logger.debug("Using FAIR-EVA's plugin: %s" % self.name)

# Metadata gathering
Expand Down
8 changes: 4 additions & 4 deletions plugins/gbif/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class Plugin(EvaluatorBase):
item_id : str
Digital Object identifier, which can be a generic one (DOI, PID), or an internal (e.g. andentifier from the repo)
oai_base : str
api_endpoint : str
Open Archives Initiative , This is the place in which the API will ask for the metadata. If you are working with Digital CSIC http://digital.csic.es/dspace-oai/request
lang : Language
"""

def __init__(self, item_id, oai_base=None, lang="en", config=None, name="gbif"):
def __init__(self, item_id, api_endpoint=None, lang="en", config=None, name="gbif"):

self.config = config
self.name = name
self.lang = lang
self.oai_base = oai_base
super().__init__(item_id, oai_base, self.lang, self.config, self.name)
self.oai_base = api_endpoint
super().__init__(item_id, self.oai_base, self.lang, self.config, self.name)
logger.debug("Using FAIR-EVA's plugin: %s" % self.name)
global _
_ = super().translation()
Expand Down
10 changes: 6 additions & 4 deletions plugins/oai-pmh/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ class Plugin(EvaluatorBase):
----------
item_id : str
Digital Object identifier, which can be a generic one (DOI, PID), or an internal (e.g. an identifier from the repo)
oai_base : str
api_endpoint : str
Open Archives initiative , This is the place in which the API will ask for the metadata
lang : Language
"""

def __init__(self, item_id, oai_base=None, lang="en", config=None, name="oai-pmh"):
def __init__(
self, item_id, api_endpoint=None, lang="en", config=None, name="oai-pmh"
):
self.config = config
self.name = name
self.lang = lang
self.oai_base = oai_base
super().__init__(item_id, oai_base, self.lang, self.config, self.name)
self.oai_base = api_endpoint
super().__init__(item_id, self.oai_base, self.lang, self.config, self.name)
logger.debug("Using FAIR-EVA's plugin: %s" % self.name)
global _
_ = super().translation()
Expand Down

0 comments on commit c6c0a6b

Please sign in to comment.