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

Function compat_open

awscli/compat.py:201–217  ·  view source on GitHub ↗

Back-port open() that accepts an encoding argument. In python3 this uses the built in open() and in python2 this uses the io.open() function. If the file is not being opened in binary mode, then we'll use getpreferredencoding() to find the preferred encoding.

(filename, mode='r', encoding=None, access_permissions=None)

Source from the content-addressed store, hash-verified

199
200
201def compat_open(filename, mode='r', encoding=None, access_permissions=None):
202 """Back-port open() that accepts an encoding argument.
203
204 In python3 this uses the built in open() and in python2 this
205 uses the io.open() function.
206
207 If the file is not being opened in binary mode, then we'll
208 use getpreferredencoding() to find the preferred
209 encoding.
210
211 """
212 opener = os.open
213 if access_permissions is not None:
214 opener = partial(os.open, mode=access_permissions)
215 if 'b' not in mode:
216 encoding = getpreferredencoding()
217 return open(filename, mode, encoding=encoding, opener=opener)
218
219
220def bytes_print(statement, stdout=None):

Callers 11

test_user_dataMethod · 0.90
get_fileFunction · 0.90
save_queryMethod · 0.90
_save_fileMethod · 0.90
load_kubeconfigMethod · 0.90
write_kubeconfigMethod · 0.90
__init__Method · 0.90
load_template_fileMethod · 0.90
_get_file_contentsMethod · 0.90

Calls 1

getpreferredencodingFunction · 0.85