MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / stream_file

Function stream_file

src/dotenv/cli.py:52–64  ·  view source on GitHub ↗

Open a file and yield the corresponding (decoded) stream. Exits with error code 2 if the file cannot be opened.

(path: os.PathLike)

Source from the content-addressed store, hash-verified

50
51@contextmanager
52def stream_file(path: os.PathLike) -> Iterator[IO[str]]:
53 """
54 Open a file and yield the corresponding (decoded) stream.
55
56 Exits with error code 2 if the file cannot be opened.
57 """
58
59 try:
60 with open(path) as stream:
61 yield stream
62 except OSError as exc:
63 print(f"Error opening env file: {exc}", file=sys.stderr)
64 exit(2)
65
66
67@cli.command()

Callers 2

listFunction · 0.85
getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected