"""Module for managing the PROJ network settings."""importosfrompathlibimportPathimportcertififrompyproj._contextimport_set_context_ca_bundle_pathfrompyproj._networkimport(# noqa: F401 pylint: disable=unused-importis_network_enabled,set_network_enabled,)
[docs]defset_ca_bundle_path(ca_bundle_path:Path|str|bool|None=None)->None:""" .. versionadded:: 3.0.0 Sets the path to the CA Bundle used by the `curl` built into PROJ when PROJ network is enabled. See: :c:func:`proj_context_set_ca_bundle_path` Environment variables: - PROJ_CURL_CA_BUNDLE - CURL_CA_BUNDLE - SSL_CERT_FILE Parameters ---------- ca_bundle_path: Path | str | bool | None, optional Default is None, which only uses the `certifi` package path as a fallback if the environment variables are not set. If a path is passed in, then that will be the path used. If it is set to True, then it will default to using the path provided, by the `certifi` package. If it is set to False or an empty string then it will default to the system settings or environment variables. """env_var_names=("PROJ_CURL_CA_BUNDLE","CURL_CA_BUNDLE","SSL_CERT_FILE")ifca_bundle_pathisFalse:# need to reset CA Bundle path to use system settings# or environment variables because it# could have been changed by the user previouslyca_bundle_path=""elifisinstance(ca_bundle_path,(str,Path)):ca_bundle_path=str(ca_bundle_path)elif(ca_bundle_pathisTrue)ornotany(env_var_nameinos.environforenv_var_nameinenv_var_names):ca_bundle_path=certifi.where()else:# reset CA Bundle path to use system settings# or environment variablesca_bundle_path=""_set_context_ca_bundle_path(ca_bundle_path)