Coverage for src/tomcli/cli/_util.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.2.3, created at 2023-04-13 11:39 +0300

1# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me> 

2# 

3# SPDX-License-Identifier: MIT 

4from __future__ import annotations 

5 

6from collections.abc import Iterable 

7from contextlib import contextmanager 

8from typing import IO 

9 

10 

11@contextmanager 

12def _std_cm(path: str, dash_stream: str, mode: str) -> Iterable[IO[Any]]: 

13 if str(path) == "-": 

14 yield dash_stream 

15 else: 

16 with open(path, mode) as fp: 

17 yield fp