__init__.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from . import streams, console #, readline_hook
  2. from .info import WINDOWS, PY2
  3. if PY2:
  4. from . import raw_input
  5. if PY2 and WINDOWS:
  6. from . import unicode_argv
  7. # PY3 # def enable(*,
  8. def enable(
  9. stdin = Ellipsis,
  10. stdout = Ellipsis,
  11. stderr = Ellipsis,
  12. use_readline_hook = False,
  13. use_pyreadline = True,
  14. use_raw_input = True, # PY2
  15. raw_input__return_unicode = raw_input.RETURN_UNICODE if PY2 else None,
  16. use_unicode_argv = False, # PY2, has some issues
  17. use_repl = False#,
  18. ):
  19. if not WINDOWS:
  20. return
  21. streams.enable(stdin=stdin, stdout=stdout, stderr=stderr)
  22. #if use_readline_hook:
  23. # readline_hook.enable(use_pyreadline=use_pyreadline)
  24. if PY2 and use_raw_input:
  25. raw_input.enable(raw_input__return_unicode)
  26. if PY2 and use_unicode_argv:
  27. unicode_argv.enable()
  28. if use_repl:
  29. console.enable()
  30. def disable():
  31. if not WINDOWS:
  32. return
  33. if console.running_console is not None:
  34. console.disable()
  35. if PY2:
  36. unicode_argv.disable()
  37. raw_input.disable()
  38. #readline_hook.disable()
  39. streams.disable()