@@ -208,7 +208,7 @@ def publish(self, data):
208208 for k , v in published ["links" ].items ():
209209 set_env_and_output (k , v )
210210
211- def upload_metadata (self , upload , zenodo_json , version , html_url = None ):
211+ def upload_metadata (self , upload , zenodo_json , version , html_url = None , title = None , description = None ):
212212 """
213213 Given an upload response and zenodo json, upload new data
214214
@@ -229,14 +229,21 @@ def upload_metadata(self, upload, zenodo_json, version, html_url=None):
229229
230230 # Update the related info to use the url to the current release
231231 if html_url :
232- metadata ["related_identifiers" ] = [
232+ metadata .setdefault ("related_identifiers" , [])
233+ metadata ["related_identifiers" ].append (
233234 {
234235 "identifier" : html_url ,
235236 "relation" : "isSupplementTo" ,
236237 "resource_type" : "software" ,
237238 "scheme" : "url" ,
238239 }
239- ]
240+ )
241+
242+ if title is not None :
243+ metadata ["title" ] = title
244+
245+ if description is not None :
246+ metadata ["description" ] = description
240247
241248 # Make the deposit!
242249 url = "https://zenodo.org/api/deposit/depositions/%s" % upload ["id" ]
@@ -248,14 +255,13 @@ def upload_metadata(self, upload, zenodo_json, version, html_url=None):
248255 )
249256 if response .status_code != 200 :
250257 sys .exit (
251- "Trouble uploading metadata %s, %s" % response .status_code ,
252- response .json (),
258+ "Trouble uploading metadata %s, %s" % (response .status_code , response .json ())
253259 )
254260 return response .json ()
255261
256262
257263def upload_archive (
258- archive , version , html_url = None , zenodo_json = None , doi = None , sandbox = False
264+ archive , version , html_url = None , zenodo_json = None , doi = None , sandbox = False , title = None , description = None ,
259265):
260266 """
261267 Upload an archive to an existing Zenodo "versions DOI"
@@ -278,7 +284,7 @@ def upload_archive(
278284 cli .upload_archive (upload , path )
279285
280286 # Finally, load .zenodo.json and add version
281- data = cli .upload_metadata (upload , zenodo_json , version , html_url )
287+ data = cli .upload_metadata (upload , zenodo_json , version , html_url , title = title , description = description )
282288
283289 # Finally, publish
284290 cli .publish (data )
@@ -300,6 +306,8 @@ def get_parser():
300306 help = "path to .zenodo.json (defaults to .zenodo.json)" ,
301307 )
302308 upload .add_argument ("--version" , help = "version to upload" )
309+ upload .add_argument ("--title" , help = "Title to override in upload" )
310+ upload .add_argument ("--description" , help = "Description to override in upload (allows HTML)" )
303311 upload .add_argument ("--doi" , help = "an existing DOI to add a new version to" )
304312 upload .add_argument (
305313 "--html-url" , dest = "html_url" , help = "url to use for the release"
@@ -333,6 +341,8 @@ def help(return_code=0):
333341 version = args .version ,
334342 doi = args .doi ,
335343 html_url = args .html_url ,
344+ title = args .title ,
345+ description = args .description ,
336346 )
337347
338348 # We should not get here :)
0 commit comments