MCPcopy Index your code
hub / github.com/aws/aws-cli / NonTranslatedStdout

Class NonTranslatedStdout

awscli/compat.py:91–112  ·  view source on GitHub ↗

This context manager sets the line-end translation mode for stdout. It is deliberately set to binary mode so that `\r` does not get added to the line ending. This can be useful when printing commands where a windows style line ending would cause errors.

Source from the content-addressed store, hash-verified

89
90
91class NonTranslatedStdout:
92 """This context manager sets the line-end translation mode for stdout.
93
94 It is deliberately set to binary mode so that `\r` does not get added to
95 the line ending. This can be useful when printing commands where a
96 windows style line ending would cause errors.
97 """
98
99 def __enter__(self):
100 if sys.platform == "win32":
101 import msvcrt
102
103 self.previous_mode = msvcrt.setmode(
104 sys.stdout.fileno(), os.O_BINARY
105 )
106 return sys.stdout
107
108 def __exit__(self, type, value, traceback):
109 if sys.platform == "win32":
110 import msvcrt
111
112 msvcrt.setmode(sys.stdout.fileno(), self.previous_mode)
113
114
115def ensure_text_type(s):

Callers 1

write_git_parametersMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected