Function to get the .config file's 'plotly_domain' without importing the chart_studio package. This property is needed to compute the default value of the plotly.js config plotlyServerURL, so it is independent of the chart_studio integration and still needs to live in Returns
()
| 676 | |
| 677 | |
| 678 | def get_config_plotly_server_url(): |
| 679 | """ |
| 680 | Function to get the .config file's 'plotly_domain' without importing |
| 681 | the chart_studio package. This property is needed to compute the default |
| 682 | value of the plotly.js config plotlyServerURL, so it is independent of |
| 683 | the chart_studio integration and still needs to live in |
| 684 | |
| 685 | Returns |
| 686 | ------- |
| 687 | str |
| 688 | """ |
| 689 | config_file = os.path.join(PLOTLY_DIR, ".config") |
| 690 | default_server_url = "https://plot.ly" |
| 691 | if not os.path.exists(config_file): |
| 692 | return default_server_url |
| 693 | with open(config_file, "rt") as f: |
| 694 | try: |
| 695 | config_dict = json.load(f) |
| 696 | if not isinstance(config_dict, dict): |
| 697 | config_dict = {} |
| 698 | except Exception: |
| 699 | # TODO: issue a warning and bubble it up |
| 700 | config_dict = {} |
| 701 | |
| 702 | return config_dict.get("plotly_domain", default_server_url) |