@@ -222,9 +222,9 @@ def set_config_file(plotly_domain=None,
222
222
ensure_local_plotly_files () # make sure what's there is OK
223
223
utils .validate_world_readable_and_sharing_settings ({
224
224
'sharing' : sharing , 'world_readable' : world_readable })
225
- settings = get_config_file ()
225
+
226
+ settings = get_config_file (validate = False )
226
227
if isinstance (plotly_domain , six .string_types ):
227
- #validate_domains(plotly_domain)
228
228
settings ['plotly_domain' ] = plotly_domain
229
229
elif plotly_domain is not None :
230
230
raise TypeError ('plotly_domain should be a string' )
@@ -233,7 +233,6 @@ def set_config_file(plotly_domain=None,
233
233
elif plotly_streaming_domain is not None :
234
234
raise TypeError ('plotly_streaming_domain should be a string' )
235
235
if isinstance (plotly_api_domain , six .string_types ):
236
- #validate_domains(plotly_api_domain)
237
236
settings ['plotly_api_domain' ] = plotly_api_domain
238
237
elif plotly_api_domain is not None :
239
238
raise TypeError ('plotly_api_domain should be a string' )
@@ -250,6 +249,14 @@ def set_config_file(plotly_domain=None,
250
249
elif auto_open is not None :
251
250
raise TypeError ('auto_open should be a boolean' )
252
251
252
+ # validate plotly_domain and plotly_api_domain
253
+ list_of_domains = []
254
+ if plotly_domain is not None :
255
+ list_of_domains .append (plotly_domain )
256
+ if plotly_api_domain is not None :
257
+ list_of_domains .append (plotly_api_domain )
258
+ validate_domains (* list_of_domains )
259
+
253
260
if isinstance (world_readable , bool ):
254
261
settings ['world_readable' ] = world_readable
255
262
settings .pop ('sharing' )
@@ -265,7 +272,7 @@ def set_config_file(plotly_domain=None,
265
272
ensure_local_plotly_files () # make sure what we just put there is OK
266
273
267
274
268
- def get_config_file (* args ):
275
+ def get_config_file (* args , validate = True ):
269
276
"""Return specified args from `~/.plotly/.config`. as tuple.
270
277
271
278
Returns all if no arguments are specified.
@@ -285,7 +292,8 @@ def get_config_file(*args):
285
292
if domain in returned_obj :
286
293
list_of_domains .append (returned_obj [domain ])
287
294
288
- validate_domains (* list_of_domains )
295
+ if validate :
296
+ validate_domains (* list_of_domains )
289
297
290
298
return returned_obj
291
299
@@ -325,7 +333,7 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
325
333
326
334
"""
327
335
plotly_rest_url = (session .get_session_config ().get ('plotly_domain' ) or
328
- get_config_file ()['plotly_domain' ])
336
+ get_config_file (validate = False )['plotly_domain' ])
329
337
if file_id is None : # assume we're using a url
330
338
url = file_owner_or_url
331
339
if url [:len (plotly_rest_url )] != plotly_rest_url :
@@ -422,7 +430,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
422
430
if file_id :
423
431
plotly_domain = (
424
432
session .get_session_config ().get ('plotly_domain' ) or
425
- get_config_file ()['plotly_domain' ]
433
+ get_config_file (validate = False )['plotly_domain' ]
426
434
)
427
435
url = "{plotly_domain}/~{un}/{fid}" .format (
428
436
plotly_domain = plotly_domain ,
@@ -448,7 +456,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
448
456
449
457
450
458
### mpl-related tools ###
451
- @utils .template_doc (** get_config_file ())
459
+ @utils .template_doc (** get_config_file (validate = False ))
452
460
def mpl_to_plotly (fig , resize = False , strip_style = False , verbose = False ):
453
461
"""Convert a matplotlib figure to plotly dictionary and send.
454
462
0 commit comments