diff --git a/pyproject.toml b/pyproject.toml index b3c0b4bc..f3d90e1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,7 @@ git_add_contributors = "hermes.commands.process.git:add_contributors" git_add_branch = "hermes.commands.process.git:add_branch" [tool.poetry.plugins."hermes.deposit"] +file = "hermes.commands.deposit.file:FileDepositPlugin" invenio = "hermes.commands.deposit.invenio:InvenioDepositPlugin" [tool.poetry.plugins."hermes.postprocess"] diff --git a/src/hermes/commands/deposit/file.py b/src/hermes/commands/deposit/file.py index 0878cbf4..798635a2 100644 --- a/src/hermes/commands/deposit/file.py +++ b/src/hermes/commands/deposit/file.py @@ -7,24 +7,19 @@ import json -import click - from hermes import config -from hermes.model.context import CodeMetaContext +from hermes.commands.deposit.base import BaseDepositPlugin from hermes.model.path import ContextPath -def dummy_noop(click_ctx: click.Context, ctx: CodeMetaContext): - pass - - -def map_metadata(click_ctx: click.Context, ctx: CodeMetaContext): - ctx.update(ContextPath.parse('deposit.file'), ctx['codemeta']) +class FileDepositPlugin(BaseDepositPlugin): + def map(self) -> None: + self.ctx.update(ContextPath.parse('deposit.file'), self.ctx['codemeta']) -def publish(click_ctx: click.Context, ctx: CodeMetaContext): - file_config = config.get("deposit").get("file", {}) - output_data = ctx['deposit.file'] + def publish(self) -> None: + file_config = config.get("deposit").get("file", {}) + output_data = self.ctx['deposit.file'] - with open(file_config.get('filename', 'hermes.json'), 'w') as deposition_file: - json.dump(output_data, deposition_file) + with open(file_config.get('filename', 'hermes.json'), 'w') as deposition_file: + json.dump(output_data, deposition_file, indent=2)