MCPcopy
hub / github.com/httpie/cli / Environment

Class Environment

httpie/context.py:46–217  ·  view source on GitHub ↗

Information about the execution context (standard streams, config directory, etc). By default, it represents the actual environment. All of the attributes can be overwritten though, which is used by the test suite to simulate various scenarios.

Source from the content-addressed store, hash-verified

44
45
46class Environment:
47 """
48 Information about the execution context
49 (standard streams, config directory, etc).
50
51 By default, it represents the actual environment.
52 All of the attributes can be overwritten though, which
53 is used by the test suite to simulate various scenarios.
54
55 """
56 args = argparse.Namespace()
57 is_windows: bool = is_windows
58 config_dir: Path = DEFAULT_CONFIG_DIR
59 stdin: Optional[IO] = sys.stdin # `None` when closed fd (#791)
60 stdin_isatty: bool = stdin.isatty() if stdin else False
61 stdin_encoding: str = None
62 stdout: IO = sys.stdout
63 stdout_isatty: bool = stdout.isatty()
64 stdout_encoding: str = None
65 stderr: IO = sys.stderr
66 stderr_isatty: bool = stderr.isatty()
67 colors = 256
68 program_name: str = 'http'
69
70 # Whether to show progress bars / status spinners etc.
71 show_displays: bool = True
72
73 if not is_windows:
74 if curses:
75 try:
76 curses.setupterm()
77 colors = curses.tigetnum('colors')
78 except curses.error:
79 pass
80 else:
81 # noinspection PyUnresolvedReferences
82 import colorama.initialise
83 stdout = colorama.initialise.wrap_stream(
84 stdout, convert=None, strip=None,
85 autoreset=True, wrap=True
86 )
87 stderr = colorama.initialise.wrap_stream(
88 stderr, convert=None, strip=None,
89 autoreset=True, wrap=True
90 )
91 del colorama
92
93 def __init__(self, devnull=None, **kwargs):
94 """
95 Use keyword arguments to overwrite
96 any of the class attributes for this instance.
97
98 """
99 assert all(hasattr(type(self), attr) for attr in kwargs.keys())
100 self.__dict__.update(**kwargs)
101
102 # The original STDERR unaffected by --quiet’ing.
103 self._orig_stderr = self.stderr

Callers 6

mainFunction · 0.90
raw_mainFunction · 0.70
mainFunction · 0.70
__init__Method · 0.50
__init__Method · 0.50

Calls

no outgoing calls

Tested by 1