errors.py 592 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Aug 15 17:33:27 2012
  4. @author: pietro
  5. """
  6. from grass.script import warning
  7. class GrassError(Exception):
  8. def __init__(self, value):
  9. self.value = value
  10. def __str__(self):
  11. return repr(self.value)
  12. class OpenError(Exception):
  13. def __init__(self, value):
  14. self.value = value
  15. def __str__(self):
  16. return repr(self.value)
  17. def must_be_open(method):
  18. def wrapper(self):
  19. if self.is_open():
  20. return method(self)
  21. else:
  22. warning(_("The map is close!"))
  23. return wrapper