6767from path import Path
6868from rich import print # noqa: A004
6969
70- from stepup .core .api import amend
70+ from stepup .core .api import amend , getenv
7171
7272
7373class RESTError (Exception ):
@@ -490,6 +490,12 @@ def to_zenodo(self) -> dict[str, Any]:
490490 }
491491
492492
493+ def _convert_license (arg ):
494+ if isinstance (arg , str ):
495+ arg = [arg ]
496+ return [lic .lower () for lic in arg ]
497+
498+
493499@attrs .define
494500class Metadata :
495501 """A subset of Invenio RDM metadata.
@@ -499,7 +505,7 @@ class Metadata:
499505
500506 title : str = attrs .field (validator = attrs .validators .min_len (1 ))
501507 version : str = attrs .field ()
502- license : str = attrs .field (converter = lambda s : s . strip (). lower () )
508+ license : str | list [ str ] = attrs .field (converter = _convert_license )
503509 resource_type : str = attrs .field (validator = attrs .validators .in_ (RESOURCE_TYPES ))
504510 copyright : str | None = attrs .field (default = None )
505511 publisher : str | None = attrs .field (default = None )
@@ -514,7 +520,7 @@ def to_zenodo(self) -> dict[str, Any]:
514520 data = {
515521 "title" : self .title ,
516522 "version" : self .version ,
517- "rights" : [{"id" : self .license } ],
523+ "rights" : [{"id" : lic } for lic in self .license ],
518524 "resource_type" : {"id" : self .resource_type },
519525 "creators" : [creator .to_zenodo () for creator in self .creators ],
520526 "description" : self .description ,
@@ -608,7 +614,7 @@ def edit_record(self, rid: int):
608614
609615 def publish_record (self , rid : int ):
610616 """Publish are draft record or a record in edit mode."""
611- self .rest .post (f"records/{ rid } /actions/publish" )
617+ self .rest .post (f"records/{ rid } /draft/ actions/publish" )
612618
613619 def start_uploads (self , rid : int , paths : list [Path ]):
614620 self .rest .post (f"records/{ rid } /draft/files" , json = [{"key" : path .name } for path in paths ])
@@ -676,6 +682,10 @@ def sync_zenodo_tool(args: argparse.Namespace) -> int:
676682 for line in cattrs .transform_error (exc , repr (args .config )):
677683 print (line )
678684 raise
685+ # Override the token path from the config file if the environment variable is set.
686+ path_token = getenv ("REPREP_PATH_ZENODO_TOKEN" )
687+ if path_token is not None :
688+ config .path_token = path_token
679689 if args .clean :
680690 clean_online (config , args .verbose )
681691 update_online (config , args .verbose )
0 commit comments