MCPcopy Index your code
hub / github.com/plotly/plotly.py / get_chrome

Function get_chrome

plotly/io/_kaleido.py:869–919  ·  view source on GitHub ↗

Get the path to the Chrome executable for Kaleido. This function is used by the `plotly_get_chrome` command line utility. Parameters ---------- path: str or Path or None The path to the directory where Chrome should be installed. If None, the default download pa

(path: Union[str, Path, None] = None)

Source from the content-addressed store, hash-verified

867
868
869def get_chrome(path: Union[str, Path, None] = None) -> Path:
870 """
871 Get the path to the Chrome executable for Kaleido.
872 This function is used by the `plotly_get_chrome` command line utility.
873
874 Parameters
875 ----------
876 path: str or Path or None
877 The path to the directory where Chrome should be installed.
878 If None, the default download path will be used.
879 """
880 if not kaleido_available() or kaleido_major() < 1:
881 raise ValueError(
882 """
883This command requires Kaleido v1.0.0 or greater.
884Install it using `pip install 'kaleido>=1.0.0'` or `pip install 'plotly[kaleido]'`."
885"""
886 )
887
888 # Use default download path if no path was specified
889 if path:
890 user_specified_path = True
891 chrome_install_path = Path(path) # Ensure it's a Path object
892 else:
893 user_specified_path = False
894 from choreographer.cli.defaults import default_download_path
895
896 chrome_install_path = default_download_path
897
898 # If install path was chosen by user, make sure there is an existing directory
899 # located at chrome_install_path; otherwise fail
900 if user_specified_path:
901 if not chrome_install_path.exists():
902 raise ValueError(
903 f"""
904The specified install path '{chrome_install_path}' does not exist.
905Please specify a path to an existing directory using the --path argument,
906or omit the --path argument to use the default download path.
907"""
908 )
909 # Make sure the path is a directory
910 if not chrome_install_path.is_dir():
911 raise ValueError(
912 f"""
913The specified install path '{chrome_install_path}' already exists but is not a directory.
914Please specify a path to an existing directory using the --path argument,
915or omit the --path argument to use the default download path.
916"""
917 )
918
919 return kaleido.get_chrome_sync(path=chrome_install_path)
920
921
922__all__ = ["to_image", "write_image", "scope", "full_figure_for_development"]

Callers 1

plotly_get_chromeFunction · 0.85

Calls 2

kaleido_availableFunction · 0.85
kaleido_majorFunction · 0.85

Tested by

no test coverage detected