Uploaded Test files
This commit is contained in:
parent
f584ad9d97
commit
2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions
47
venv/Lib/site-packages/nbconvert/utils/io.py
Normal file
47
venv/Lib/site-packages/nbconvert/utils/io.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
# coding: utf-8
|
||||
"""io-related utilities"""
|
||||
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
def unicode_std_stream(stream='stdout'):
|
||||
u"""Get a wrapper to write unicode to stdout/stderr as UTF-8.
|
||||
|
||||
This ignores environment variables and default encodings, to reliably write
|
||||
unicode to stdout or stderr.
|
||||
|
||||
::
|
||||
|
||||
unicode_std_stream().write(u'ł@e¶ŧ←')
|
||||
"""
|
||||
assert stream in ('stdout', 'stderr')
|
||||
stream = getattr(sys, stream)
|
||||
|
||||
try:
|
||||
stream_b = stream.buffer
|
||||
except AttributeError:
|
||||
# sys.stdout has been replaced - use it directly
|
||||
return stream
|
||||
|
||||
return codecs.getwriter('utf-8')(stream_b)
|
||||
|
||||
def unicode_stdin_stream():
|
||||
u"""Get a wrapper to read unicode from stdin as UTF-8.
|
||||
|
||||
This ignores environment variables and default encodings, to reliably read unicode from stdin.
|
||||
|
||||
::
|
||||
|
||||
totreat = unicode_stdin_stream().read()
|
||||
"""
|
||||
stream = sys.stdin
|
||||
try:
|
||||
stream_b = stream.buffer
|
||||
except AttributeError:
|
||||
return stream
|
||||
|
||||
return codecs.getreader('utf-8')(stream_b)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue