-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
40 lines (34 loc) · 971 Bytes
/
Copy pathconsole.py
File metadata and controls
40 lines (34 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright 2024 John Sirois.
# Licensed under the Apache License, Version 2.0 (see LICENSE).
import os
import sys
from dataclasses import dataclass
from typing import Any, TextIO
import aioconsole
@dataclass(frozen=True)
class Console:
quiet: bool = False
def print(
self,
*values: Any,
sep: str = " ",
end: str = os.linesep,
flush: bool = True,
file: TextIO = sys.stdout,
force: bool = False,
) -> None:
if self.quiet and not force:
return
print(*values, sep=sep, end=end, flush=flush, file=file)
async def aprint(
self,
*values: Any,
sep: str = " ",
end: str = os.linesep,
flush: bool = True,
use_stderr: bool = False,
force: bool = False,
) -> None:
if self.quiet and not force:
return
await aioconsole.aprint(*values, sep=sep, end=end, flush=flush, use_stderr=use_stderr)