errors.py 766 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Aug 15 17:33:27 2012
  4. @author: pietro
  5. """
  6. from functools import wraps
  7. from grass.pygrass.messages import get_msgr
  8. class AbstractError(Exception):
  9. def __init__(self, value):
  10. self.value = value
  11. def __str__(self):
  12. return repr(self.value)
  13. class ParameterError(Exception):
  14. pass
  15. class FlagError(Exception):
  16. pass
  17. class DBError(AbstractError):
  18. pass
  19. class GrassError(AbstractError):
  20. pass
  21. class OpenError(AbstractError):
  22. pass
  23. def must_be_open(method):
  24. @wraps(method)
  25. def wrapper(self, *args, **kargs):
  26. if self.is_open():
  27. return method(self, *args, **kargs)
  28. else:
  29. get_msgr().warning(_("The map is close!"))
  30. return wrapper