site.py 658 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # vim:fileencoding=utf-8
  3. # License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
  4. import _sitebuiltins
  5. import builtins
  6. import sys
  7. def set_quit() -> None:
  8. eof = 'Ctrl-D (i.e. EOF)'
  9. builtins.quit = _sitebuiltins.Quitter('quit', eof)
  10. builtins.exit = _sitebuiltins.Quitter('exit', eof)
  11. def set_helper() -> None:
  12. builtins.help = _sitebuiltins._Helper()
  13. def main() -> None:
  14. sys.argv[0] = sys.calibre_basename
  15. set_helper()
  16. set_quit()
  17. mod = __import__(sys.calibre_module, fromlist=[1])
  18. func = getattr(mod, sys.calibre_function)
  19. return func()
  20. if __name__ == '__main__':
  21. main()