diff --git a/pyproject.toml b/pyproject.toml index fa55422b..7f13c0c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,8 @@ invenio_rdm = "hermes.commands.deposit.invenio_rdm:publish" file = "hermes.commands.deposit.file:publish" [tool.poetry.plugins."hermes.postprocess"] -config_record_id = "hermes.commands.postprocess.invenio:config_record_id" +config_invenio_record_id = "hermes.commands.postprocess.invenio:config_record_id" +config_invenio_rdm_record_id = "hermes.commands.postprocess.invenio_rdm:config_record_id" cff_doi = "hermes.commands.postprocess.invenio:cff_doi" [tool.taskipy.tasks] diff --git a/src/hermes/commands/postprocess/invenio_rdm.py b/src/hermes/commands/postprocess/invenio_rdm.py new file mode 100644 index 00000000..c14a3a07 --- /dev/null +++ b/src/hermes/commands/postprocess/invenio_rdm.py @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: Apache-2.0 + +# SPDX-FileContributor: Michael Meinel +# SPDX-FileContributor: Stephan Druskat + +import json +import logging + +import toml +from ruamel import yaml + +from hermes import config + + +_log = logging.getLogger('deposit.invenio_rdm') + + +def config_record_id(ctx): + deposition_path = ctx.get_cache('deposit', 'deposit') + with deposition_path.open("r") as deposition_file: + deposition = json.load(deposition_file) + conf = config.get('hermes') + try: + conf['deposit']['invenio_rdm']['record_id'] = deposition['record_id'] + toml.dump(conf, open('hermes.toml', 'w')) + except KeyError: + raise RuntimeError("No deposit.invenio configuration available to store record id in") from None