aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/deprecated/python/win-unicode-console/win_unicode_console/__init__.py
blob: 7ec03c523f391e233671fd9c8ac02a203d905d56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from . import streams, console #, readline_hook
from .info import WINDOWS, PY2

if PY2:
	from . import raw_input

if PY2 and WINDOWS:
	from . import unicode_argv


# PY3 # def enable(*, 
def enable(
		stdin = Ellipsis, 
		stdout = Ellipsis, 
		stderr = Ellipsis, 
		use_readline_hook = False, 
		use_pyreadline = True, 
		use_raw_input = True, # PY2
		raw_input__return_unicode = raw_input.RETURN_UNICODE if PY2 else None, 
		use_unicode_argv = False, # PY2, has some issues
		use_repl = False#, 
	):
	
	if not WINDOWS:
		return
	
	streams.enable(stdin=stdin, stdout=stdout, stderr=stderr)
	
	#if use_readline_hook:
	#	readline_hook.enable(use_pyreadline=use_pyreadline)
	
	if PY2 and use_raw_input:
		raw_input.enable(raw_input__return_unicode)
	
	if PY2 and use_unicode_argv:
		unicode_argv.enable()
	
	if use_repl:
		console.enable()

def disable():
	if not WINDOWS:
		return
	
	if console.running_console is not None:
		console.disable()
	
	if PY2:
		unicode_argv.disable()
		raw_input.disable()
	
	#readline_hook.disable()
	streams.disable()