Install Google Chrome for Kaleido (Required for Plotly image export). This function is a command-line wrapper for `plotly.io.get_chrome()`. When running from the command line, use the command `plotly_get_chrome`; when calling from Python code, use `plotly.io.get_chrome()`.
()
| 798 | |
| 799 | |
| 800 | def plotly_get_chrome() -> None: |
| 801 | """ |
| 802 | Install Google Chrome for Kaleido (Required for Plotly image export). |
| 803 | This function is a command-line wrapper for `plotly.io.get_chrome()`. |
| 804 | |
| 805 | When running from the command line, use the command `plotly_get_chrome`; |
| 806 | when calling from Python code, use `plotly.io.get_chrome()`. |
| 807 | """ |
| 808 | |
| 809 | usage = """ |
| 810 | Usage: plotly_get_chrome [-y] [--path PATH] |
| 811 | |
| 812 | Installs Google Chrome for Plotly image export. |
| 813 | |
| 814 | Options: |
| 815 | -y Skip confirmation prompt |
| 816 | --path PATH Specify the path to install Chrome. Must be a path to an existing directory. |
| 817 | --help Show this message and exit. |
| 818 | """ |
| 819 | |
| 820 | if not kaleido_available() or kaleido_major() < 1: |
| 821 | raise ValueError( |
| 822 | """ |
| 823 | This command requires Kaleido v1.0.0 or greater. |
| 824 | Install it using `pip install 'kaleido>=1.0.0'` or `pip install 'plotly[kaleido]'`." |
| 825 | """ |
| 826 | ) |
| 827 | |
| 828 | # Handle command line arguments |
| 829 | import sys |
| 830 | |
| 831 | cli_args = sys.argv |
| 832 | |
| 833 | # Handle "-y" flag |
| 834 | cli_yes = "-y" in cli_args |
| 835 | if cli_yes: |
| 836 | cli_args.remove("-y") |
| 837 | |
| 838 | # Handle "--path" flag |
| 839 | chrome_install_path = None |
| 840 | if "--path" in cli_args: |
| 841 | path_index = cli_args.index("--path") + 1 |
| 842 | if path_index < len(cli_args): |
| 843 | chrome_install_path = cli_args[path_index] |
| 844 | cli_args.remove("--path") |
| 845 | cli_args.remove(chrome_install_path) |
| 846 | chrome_install_path = Path(chrome_install_path) |
| 847 | |
| 848 | # If any arguments remain, command syntax was incorrect -- print usage and exit |
| 849 | if len(cli_args) > 1: |
| 850 | print(usage) |
| 851 | sys.exit(1) |
| 852 | |
| 853 | if not cli_yes: |
| 854 | print( |
| 855 | f""" |
| 856 | Plotly will install a copy of Google Chrome to be used for generating static images of plots. |
| 857 | Chrome will be installed at: {chrome_install_path}""" |
nothing calls this directly
no test coverage detected