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.

28 lines
668B

  1. import sys
  2. import warnings
  3. class PyStdIsDeprecatedWarning(DeprecationWarning):
  4. pass
  5. class Std(object):
  6. """ makes top-level python modules available as an attribute,
  7. importing them on first access.
  8. """
  9. def __init__(self):
  10. self.__dict__ = sys.modules
  11. def __getattr__(self, name):
  12. warnings.warn("py.std is deprecated, please import %s directly" % name,
  13. category=PyStdIsDeprecatedWarning,
  14. stacklevel=2)
  15. try:
  16. m = __import__(name)
  17. except ImportError:
  18. raise AttributeError("py.std: could not import %s" % name)
  19. return m
  20. std = Std()