p≡p for Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

  1. # pEp package
  2. # This file is being exectued upon 'import pEp'
  3. #
  4. # __all__ could be used to limit the symbols exported when using from <pkg> import *
  5. # Import all symbols EXCEPT the ones beginning with underscore into the current namespace
  6. from native_pEp import *
  7. # TODO: inter-pkg ref to make sure which native_pEp in sys.path gets loaded
  8. # like: pEp.native_pEp
  9. # import the module
  10. import native_pEp
  11. # Executed on module import
  12. def init():
  13. print(init, "called")
  14. native_pEp._init_after_main_module()
  15. def message_to_send(msg):
  16. """
  17. message_to_send(msg)
  18. override pEp.message_to_send(msg) with your own implementation
  19. this callback is being called when a pp management message needs to be sent
  20. GIL CAVEAT
  21. """
  22. print("message_to_send() - default callback\n")
  23. print("overwrite this method")
  24. def notify_handshake(me, partner, signal):
  25. """
  26. notifyHandshake(self, me, partner)
  27. me own identity
  28. partner identity of communication partner
  29. signal the handshake signal
  30. overwrite this method with an implementation of a handshake dialog
  31. GIL CAVEAT
  32. """
  33. print("message_to_send() - default callback\n")
  34. print("overwrite this method")
  35. # Executed when run as script
  36. def main():
  37. print("I am being run as a script")
  38. # MAIN
  39. if __name__ == "__main__":
  40. main()
  41. else:
  42. init()