Skip to content

Commit d1a5db3

Browse files
committed
Added Rodare as DepositOption (not tested)
1 parent 7ed8c03 commit d1a5db3

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

src/hermes/commands/init/base.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class DepositId(Enum):
4545
ZenodoSandbox = auto()
4646
JuelichData = auto()
4747
DemoDataverse = auto()
48+
Rodare = auto()
49+
RodareTest = auto()
4850

4951

5052
@dataclass
@@ -73,6 +75,8 @@ def __init__(self, name: str = "", url: str = "", plugin_name: str = "", deposit
7375
DepositPlatform("Zenodo", "https://zenodo.org/", "invenio_rdm", DepositId.Zenodo),
7476
DepositPlatform("Demo Dataverse", "https://demo.dataverse.org/", "dataverse", DepositId.DemoDataverse),
7577
DepositPlatform("Jülich Data", "https://data.fz-juelich.de/", "dataverse", DepositId.JuelichData),
78+
DepositPlatform("Rodare", "https://rodare.hzdr.de/", "rodare", DepositId.Rodare),
79+
DepositPlatform("Rodare Test", "https://rodare-test.hzdr.de/", "rodare", DepositId.RodareTest),
7680
]
7781

7882

@@ -555,6 +559,18 @@ def create_dataverse_token(self):
555559
# TODO try to validate the token
556560
self.deposit_platform.token = sc.answer("Enter the token here: ")
557561

562+
def create_rodare_token(self):
563+
token_url = urljoin(self.deposit_platform.url, "account/settings/applications/tokens/new/")
564+
sc.echo("{} and create an access token.".format(
565+
sc.create_console_hyperlink(token_url, "Open this link")
566+
))
567+
sc.echo("It needs the scopes \"deposit:actions\" and \"deposit:write\".")
568+
if self.setup_method == "m":
569+
sc.press_enter_to_continue()
570+
else:
571+
# TODO try to validate the token
572+
self.deposit_platform.token = sc.answer("Enter the token here: ")
573+
558574
def configure_git_project(self) -> None:
559575
"""Adds the token to the git secrets & changes action workflow settings."""
560576
match self.git_hoster:
@@ -671,11 +687,17 @@ def integrate_deposit_platform(self) -> None:
671687
self.hermes_toml_data["deposit"][deposit_plugin]["site_url"] = self.deposit_platform.url
672688
self.ci_parameters["deposit_parameter_token"] = f"-O {deposit_plugin}.auth_token"
673689
self.ci_parameters["deposit_token_name"] = self.deposit_platform.token_name
690+
# Invenio needs access_right = "open" (no idea what that does, might be outdated)
674691
if deposit_plugin.startswith("invenio"):
675692
self.hermes_toml_data["deposit"][deposit_plugin]["access_right"] = "open"
676-
elif deposit_plugin == "dataverse":
693+
# Dataverse needs a host_dataverse name as some sort of directory where the publication will appear
694+
elif deposit_plugin.startswith("dataverse"):
677695
host_dataverse = sc.answer("Enter the name of the dataverse where you want to publish: ")
678696
self.hermes_toml_data["deposit"][deposit_plugin]["host_dataverse"] = host_dataverse
697+
# Rodare needs the robis_pub_id
698+
elif deposit_plugin.startswith("rodare"):
699+
robis_pub_id = sc.answer("Enter the corresponding Robis Publication ID: ")
700+
self.hermes_toml_data["deposit"][deposit_plugin]["robis_pub_id"] = robis_pub_id
679701

680702
def choose_setup_method(self) -> None:
681703
"""User chooses his desired setup method: Either preferring automatic (if available) or manual."""
@@ -694,11 +716,13 @@ def connect_deposit_platform(self) -> None:
694716
used_deposit_plugin = self.deposit_platform.plugin_name
695717
deposit_url = self.deposit_platform
696718
deposit_name = self.deposit_platform.name
697-
if used_deposit_plugin == "invenio_rdm":
719+
if used_deposit_plugin.startswith("invenio"):
698720
connect_zenodo.setup(zenodo_url=self.deposit_platform.url, display_name=self.deposit_platform.name)
699721
self.create_zenodo_token()
700-
elif used_deposit_plugin == "dataverse":
722+
elif used_deposit_plugin.startswith("dataverse"):
701723
self.create_dataverse_token()
724+
elif used_deposit_plugin.startswith("rodare"):
725+
self.create_rodare_token()
702726
else:
703727
sc.echo(f"Unknown deposit plugin: {used_deposit_plugin}", formatting=sc.Formats.WARNING)
704728
sc.echo(f"Getting an access token from {deposit_name} ({deposit_url}) is not supported by hermes init."

0 commit comments

Comments
 (0)