Parse a .env file and return its content as a dict. The returned dict will have `None` values for keys without values in the .env file. For example, `foo=bar` results in `{"foo": "bar"}` whereas `foo` alone results in `{"foo": None}` Parameters: dotenv_path: Absolute o
(
dotenv_path: Optional[StrPath] = None,
stream: Optional[IO[str]] = None,
verbose: bool = False,
interpolate: bool = True,
encoding: Optional[str] = "utf-8",
)
| 430 | |
| 431 | |
| 432 | def dotenv_values( |
| 433 | dotenv_path: Optional[StrPath] = None, |
| 434 | stream: Optional[IO[str]] = None, |
| 435 | verbose: bool = False, |
| 436 | interpolate: bool = True, |
| 437 | encoding: Optional[str] = "utf-8", |
| 438 | ) -> Dict[str, Optional[str]]: |
| 439 | """ |
| 440 | Parse a .env file and return its content as a dict. |
| 441 | |
| 442 | The returned dict will have `None` values for keys without values in the .env file. |
| 443 | For example, `foo=bar` results in `{"foo": "bar"}` whereas `foo` alone results in |
| 444 | `{"foo": None}` |
| 445 | |
| 446 | Parameters: |
| 447 | dotenv_path: Absolute or relative path to the .env file. |
| 448 | stream: `StringIO` object with .env content, used if `dotenv_path` is `None`. |
| 449 | verbose: Whether to output a warning if the .env file is missing. |
| 450 | encoding: Encoding to be used to read the file. |
| 451 | |
| 452 | If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the |
| 453 | .env file. |
| 454 | """ |
| 455 | if dotenv_path is None and stream is None: |
| 456 | dotenv_path = find_dotenv() |
| 457 | |
| 458 | return DotEnv( |
| 459 | dotenv_path=dotenv_path, |
| 460 | stream=stream, |
| 461 | verbose=verbose, |
| 462 | interpolate=interpolate, |
| 463 | override=True, |
| 464 | encoding=encoding, |
| 465 | ).dict() |
| 466 | |
| 467 | |
| 468 | def _is_file_or_fifo(path: StrPath) -> bool: |
no test coverage detected
searching dependent graphs…