4949ALTERNATIVE_HISTNORM = 'probability'
5050
5151
52- http_msg = (
53- "The plotly_domain and plotly_api_domain of your config file must start "
54- "with 'https', 'http'.\n If you are not using On-Prem then run the "
55- "following code to ensure your plotly_domain and plotly_api_domain start "
56- "with 'https':\n \n \n "
57- "import plotly\n "
58- "plotly.tools.set_config_file(\n "
59- " plotly_domain='https://plot.ly',\n "
60- " plotly_api_domain='https://api.plot.ly'\n "
61- ")\n \n \n "
62- "If you are using On-Prem then you will need to use your company's "
63- "domain and api_domain urls:\n \n \n "
64- "import plotly\n "
65- "plotly.tools.set_config_file(\n "
66- " plotly_domain='https://plotly.your-company.com',\n "
67- " plotly_api_domain='https://plotly.your-company.com'\n "
68- ")\n \n \n "
69- "Make sure to replace `your-company.com` with the URL of your Plotly "
70- "On-Premise server.\n See "
71- "https://plot.ly/python/getting-started/#special-instructions-for-plotly-onpremise-users "
72- "for more help with getting started with On-Prem."
73- )
74-
75-
76- def _validate_domains (* domains ):
77- for d in domains :
78- if not d .lower ().startswith ('https' ):
79- warnings .warn (http_msg , category = UserWarning )
80-
81-
8252# Warning format
8353def warning_on_one_line (message , category , filename , lineno ,
8454 file = None , line = None ):
@@ -216,14 +186,15 @@ def set_config_file(plotly_domain=None,
216186 :param (bool) world_readable: True = public, False = private
217187
218188 """
189+ # import ipdb; ipdb.set_trace()
219190 if not check_file_permissions ():
220191 raise exceptions .PlotlyError ("You don't have proper file permissions "
221192 "to run this function." )
222193 ensure_local_plotly_files () # make sure what's there is OK
223194 utils .validate_world_readable_and_sharing_settings ({
224195 'sharing' : sharing , 'world_readable' : world_readable })
225196
226- settings = get_config_file (validate = False )
197+ settings = get_config_file ()
227198 if isinstance (plotly_domain , six .string_types ):
228199 settings ['plotly_domain' ] = plotly_domain
229200 elif plotly_domain is not None :
@@ -250,12 +221,9 @@ def set_config_file(plotly_domain=None,
250221 raise TypeError ('auto_open should be a boolean' )
251222
252223 # 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 )
224+ utils .validate_plotly_domains (
225+ {'plotly_domain' : plotly_domain , 'plotly_api_domain' : plotly_api_domain }
226+ )
259227
260228 if isinstance (world_readable , bool ):
261229 settings ['world_readable' ] = world_readable
@@ -272,7 +240,7 @@ def set_config_file(plotly_domain=None,
272240 ensure_local_plotly_files () # make sure what we just put there is OK
273241
274242
275- def get_config_file (validate = True , * args ):
243+ def get_config_file (* args ):
276244 """Return specified args from `~/.plotly/.config`. as tuple.
277245
278246 Returns all if no arguments are specified.
@@ -283,19 +251,9 @@ def get_config_file(validate=True, *args):
283251 """
284252 if check_file_permissions ():
285253 ensure_local_plotly_files () # make sure what's there is OK
286- returned_obj = utils .load_json_dict (CONFIG_FILE , * args )
254+ return utils .load_json_dict (CONFIG_FILE , * args )
287255 else :
288- returned_obj = FILE_CONTENT [CONFIG_FILE ]
289-
290- list_of_domains = []
291- for domain in ['plotly_domain' , 'plotly_api_domain' ]:
292- if domain in returned_obj :
293- list_of_domains .append (returned_obj [domain ])
294-
295- if validate :
296- _validate_domains (* list_of_domains )
297-
298- return returned_obj
256+ return FILE_CONTENT [CONFIG_FILE ]
299257
300258
301259def reset_config_file ():
@@ -331,7 +289,7 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
331289
332290 """
333291 plotly_rest_url = (session .get_session_config ().get ('plotly_domain' ) or
334- get_config_file (validate = False )['plotly_domain' ])
292+ get_config_file ()['plotly_domain' ])
335293 if file_id is None : # assume we're using a url
336294 url = file_owner_or_url
337295 if url [:len (plotly_rest_url )] != plotly_rest_url :
@@ -428,7 +386,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
428386 if file_id :
429387 plotly_domain = (
430388 session .get_session_config ().get ('plotly_domain' ) or
431- get_config_file (validate = False )['plotly_domain' ]
389+ get_config_file ()['plotly_domain' ]
432390 )
433391 url = "{plotly_domain}/~{un}/{fid}" .format (
434392 plotly_domain = plotly_domain ,
@@ -454,7 +412,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
454412
455413
456414### mpl-related tools ###
457- @utils .template_doc (** get_config_file (validate = False ))
415+ @utils .template_doc (** get_config_file ())
458416def mpl_to_plotly (fig , resize = False , strip_style = False , verbose = False ):
459417 """Convert a matplotlib figure to plotly dictionary and send.
460418
0 commit comments