@@ -244,27 +244,10 @@ def update_plotlyjs(plotly_js_version, outdir):
244244
245245
246246# FIXME: switch to argparse 
247- def  update_schema_bundle_from_master ():
247+ def  update_schema_bundle_from_master (args ):
248248    """Update the plotly.js schema and bundle from master.""" 
249- 
250-     if  "--devrepo"  in  sys .argv :
251-         devrepo  =  sys .argv [sys .argv .index ("--devrepo" ) +  1 ]
252-     else :
253-         devrepo  =  "plotly/plotly.js" 
254- 
255-     if  "--devbranch"  in  sys .argv :
256-         devbranch  =  sys .argv [sys .argv .index ("--devbranch" ) +  1 ]
257-     else :
258-         devbranch  =  "master" 
259- 
260-     if  "--local"  in  sys .argv :
261-         local  =  sys .argv [sys .argv .index ("--local" ) +  1 ]
262-     else :
263-         local  =  None 
264- 
265-     if  local  is  None :
266-         build_info  =  get_latest_publish_build_info (devrepo , devbranch )
267- 
249+     if  args .local  is  None :
250+         build_info  =  get_latest_publish_build_info (args .devrepo , args .devbranch )
268251        archive_url , bundle_url , schema_url  =  get_bundle_schema_urls (
269252            build_info ["build_num" ]
270253        )
@@ -275,14 +258,14 @@ def update_schema_bundle_from_master():
275258        # Update schema in package data 
276259        overwrite_schema (schema_url )
277260    else :
278-         # this info could be more informative but 
279-         # it doesn't seem as  useful in a local context 
280-         # and requires dependencies and  programming. 
261+         # this info could be more informative but it doesn't seem as  
262+         # useful in a local context and requires dependencies and  
263+         # programming. 
281264        build_info  =  {"vcs_revision" : "local" , "committer_date" : str (time .time ())}
282-         devrepo  =  local 
283-         devbranch  =  "" 
265+         args . devrepo  =  args . local 
266+         args . devbranch  =  "" 
284267
285-         archive_uri , bundle_uri , schema_uri  =  get_bundle_schema_local (local )
268+         archive_uri , bundle_uri , schema_uri  =  get_bundle_schema_local (args . local )
286269        overwrite_bundle_local (bundle_uri )
287270        overwrite_schema_local (schema_uri )
288271
@@ -293,23 +276,23 @@ def update_schema_bundle_from_master():
293276
294277    # Replace version with bundle url 
295278    package_json ["dependencies" ]["plotly.js" ] =  (
296-         archive_url  if  local  is  None  else  archive_uri 
279+         archive_url  if  args . local  is  None  else  archive_uri 
297280    )
298281    with  open (package_json_path , "w" ) as  f :
299282        json .dump (package_json , f , indent = 2 )
300283
301284    # update plotly.js version in _plotlyjs_version 
302285    rev  =  build_info ["vcs_revision" ]
303286    date  =  str (build_info ["committer_date" ])
304-     version  =  "_" .join ([devrepo , devbranch , date [:10 ], rev [:8 ]])
287+     version  =  "_" .join ([args . devrepo , args . devbranch , date [:10 ], rev [:8 ]])
305288    overwrite_plotlyjs_version_file (version )
306-     install_js_deps (local )
289+     install_js_deps (args . local )
307290
308291
309- def  update_plotlyjs_dev (outdir ):
292+ def  update_plotlyjs_dev (args ,  outdir ):
310293    """Update project to a new development version of plotly.js.""" 
311294
312-     update_schema_bundle_from_master ()
295+     update_schema_bundle_from_master (args )
313296    perform_codegen (outdir )
314297
315298
@@ -328,7 +311,18 @@ def parse_args():
328311
329312    subparsers .add_parser ("format" , help = "reformat code" )
330313
331-     subparsers .add_parser ("updateplotlyjsdev" , help = "update plotly.js for development" )
314+     p_update_dev  =  subparsers .add_parser (
315+         "updateplotlyjsdev" , help = "update plotly.js for development" 
316+     )
317+     p_update_dev .add_argument (
318+         "--devrepo" , default = "plotly/plotly.js" , help = "repository" 
319+     )
320+     p_update_dev .add_argument (
321+         "--devbranch" , default = "master" , help = "branch" 
322+     )
323+     p_update_dev .add_argument (
324+         "--local" , default = None , help = "local path" 
325+     )
332326
333327    subparsers .add_parser ("updateplotlyjs" , help = "update plotly.js" )
334328
@@ -353,7 +347,7 @@ def main():
353347        lint_code (outdir )
354348
355349    elif  args .cmd  ==  "updateplotlyjsdev" :
356-         update_plotlyjs_dev (outdir )
350+         update_plotlyjs_dev (args ,  outdir )
357351
358352    elif  args .cmd  ==  "updateplotlyjs" :
359353        version  =  plotly_js_version ()
0 commit comments