Skip to content

helpers#

get_metax_identifiers_by_pid#

Source code in src/apps/core/helpers.py
def get_metax_identifiers_by_pid(identifier, context={}):
    pid = clean_pid(identifier)
    if (pid_map := context.get("datasets_by_pid")) is not None:
        return pid_map.get(pid, [])
    return list(
        Dataset.available_objects.filter(
            persistent_identifier=pid, state=Dataset.StateChoices.PUBLISHED
        ).values_list("id", flat=True)
    )

clean_pid#

Source code in src/apps/core/helpers.py
def clean_pid(pid_string):
    doi_replaced = re.sub("^https://doi.org/", "doi:", pid_string)
    urn_removed = re.sub("^http://urn.fi/", "", doi_replaced)
    return urn_removed