@@ -244,27 +244,10 @@ def update_plotlyjs(plotly_js_version, outdir):
244
244
245
245
246
246
# FIXME: switch to argparse
247
- def update_schema_bundle_from_master ():
247
+ def update_schema_bundle_from_master (args ):
248
248
"""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 )
268
251
archive_url , bundle_url , schema_url = get_bundle_schema_urls (
269
252
build_info ["build_num" ]
270
253
)
@@ -275,14 +258,14 @@ def update_schema_bundle_from_master():
275
258
# Update schema in package data
276
259
overwrite_schema (schema_url )
277
260
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.
281
264
build_info = {"vcs_revision" : "local" , "committer_date" : str (time .time ())}
282
- devrepo = local
283
- devbranch = ""
265
+ args . devrepo = args . local
266
+ args . devbranch = ""
284
267
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 )
286
269
overwrite_bundle_local (bundle_uri )
287
270
overwrite_schema_local (schema_uri )
288
271
@@ -293,23 +276,23 @@ def update_schema_bundle_from_master():
293
276
294
277
# Replace version with bundle url
295
278
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
297
280
)
298
281
with open (package_json_path , "w" ) as f :
299
282
json .dump (package_json , f , indent = 2 )
300
283
301
284
# update plotly.js version in _plotlyjs_version
302
285
rev = build_info ["vcs_revision" ]
303
286
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 ]])
305
288
overwrite_plotlyjs_version_file (version )
306
- install_js_deps (local )
289
+ install_js_deps (args . local )
307
290
308
291
309
- def update_plotlyjs_dev (outdir ):
292
+ def update_plotlyjs_dev (args , outdir ):
310
293
"""Update project to a new development version of plotly.js."""
311
294
312
- update_schema_bundle_from_master ()
295
+ update_schema_bundle_from_master (args )
313
296
perform_codegen (outdir )
314
297
315
298
@@ -328,7 +311,18 @@ def parse_args():
328
311
329
312
subparsers .add_parser ("format" , help = "reformat code" )
330
313
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
+ )
332
326
333
327
subparsers .add_parser ("updateplotlyjs" , help = "update plotly.js" )
334
328
@@ -353,7 +347,7 @@ def main():
353
347
lint_code (outdir )
354
348
355
349
elif args .cmd == "updateplotlyjsdev" :
356
- update_plotlyjs_dev (outdir )
350
+ update_plotlyjs_dev (args , outdir )
357
351
358
352
elif args .cmd == "updateplotlyjs" :
359
353
version = plotly_js_version ()
0 commit comments