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

Function validate_preferred_output_encoding

awscli/compat.py:138–153  ·  view source on GitHub ↗

Validate that the preferred output encoding is valid if it's set. We do this separately from set_preferred_output_encoding because that may be called from error handlers while handling another exception, which we still want to print successfully.

()

Source from the content-addressed store, hash-verified

136
137
138def validate_preferred_output_encoding():
139 """
140 Validate that the preferred output encoding is valid if it's set.
141 We do this separately from set_preferred_output_encoding because that
142 may be called from error handlers while handling another exception, which
143 we still want to print successfully.
144 """
145 if OUTPUT_ENCODING_ENV_VAR in os.environ:
146 try:
147 ''.encode(os.environ[OUTPUT_ENCODING_ENV_VAR])
148 except LookupError:
149 raise ValueError(
150 f'Unknown codec `'
151 f'{os.environ[OUTPUT_ENCODING_ENV_VAR]}` '
152 f'specified for {OUTPUT_ENCODING_ENV_VAR}.'
153 )
154
155
156def set_preferred_output_encoding(stream):

Callers 2

mainMethod · 0.90

Calls 1

encodeMethod · 0.45

Tested by 1