Ejemplo n.º 1
0
def enable(*, 
	streams=["stdin", "stdout", "stderr"], 
	transcode=None, 
	use_readline_hook=True, 
	use_pyreadline=True,
	use_repl=False):
	
	if transcode is None:
		if use_readline_hook and use_pyreadline and readline_hook.pyreadline:
			transcode = True
				# pyreadline assumes that encoding of all sys.stdio objects is the same
			
		elif use_repl:
			transcode = False
			
		else:
			transcode = True
				# actually Python REPL assumes that sys.stdin.encoding == sys.stdout.encoding and cannot handle UTF-16 on both input and output
	
	streams_.enable(streams, transcode=transcode)
	
	if use_readline_hook:
		readline_hook.enable(use_pyreadline=use_pyreadline)
	
	if use_repl:
		console.enable()
Ejemplo n.º 2
0
def enable(*,
           streams=["stdin", "stdout", "stderr"],
           transcode=None,
           use_readline_hook=True,
           use_pyreadline=True,
           use_repl=False):

    if transcode is None:
        if use_readline_hook and use_pyreadline and readline_hook.pyreadline:
            transcode = True
            # pyreadline assumes that encoding of all sys.stdio objects is the same

        elif use_repl:
            transcode = False

        else:
            transcode = True
            # actually Python REPL assumes that sys.stdin.encoding == sys.stdout.encoding and cannot handle UTF-16 on both input and output

    streams_.enable(streams, transcode=transcode)

    if use_readline_hook:
        readline_hook.enable(use_pyreadline=use_pyreadline)

    if use_repl:
        console.enable()
Ejemplo n.º 3
0
def run():
	global run
	del run
	
	import sys
	from win_unicode_console import runner, console, streams
	
	streams.enable(transcode=False)	# transcoding not needed with custom REPL
	script_provided = len(sys.argv) > 1
	
	if script_provided:
		runner.run_script()
	
	if sys.flags.interactive or not script_provided:
		if sys.flags.interactive and not script_provided:
			console.print_banner()
		try:
			console.enable()
		finally:
			runner.set_inspect_flag(0)