__init__.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # -*- coding: utf-8 -*-
  2. class NotFoundError(Exception):
  3. pass
  4. class CST(object):
  5. STATUS_ERROR = 'error'
  6. STATUS_OK = 'ok'
  7. STATUS_WARNING = 'warning'
  8. class TREEVIEW_MENU(object):
  9. """
  10. Constant values used for tree view menu generation
  11. """
  12. ITEM_SEPARATOR = '__'
  13. ID_SEPARATOR = '_'
  14. ID_TEMPLATE__WORKSPACE_ONLY='workspace_{}__'
  15. ID_TEMPLATE__FULL='workspace_{}__content_{}'
  16. #############
  17. #
  18. # HERE ARE static messages which allow to get translation for dates
  19. #
  20. # FIXME - MAKE months translatable
  21. # l_('January')
  22. # l_('February')
  23. # l_('March')
  24. # l_('April')
  25. # l_('May')
  26. # l_('June')
  27. # l_('July')
  28. # l_('August')
  29. # l_('September')
  30. # l_('October')
  31. # l_('November')
  32. # l_('December')
  33. def cmp_to_key(mycmp):
  34. """
  35. List sort related function
  36. Convert a cmp= function into a key= function
  37. """
  38. class K(object):
  39. def __init__(self, obj, *args):
  40. self.obj = obj
  41. def __lt__(self, other):
  42. return mycmp(self.obj, other.obj) < 0
  43. def __gt__(self, other):
  44. return mycmp(self.obj, other.obj) > 0
  45. def __eq__(self, other):
  46. return mycmp(self.obj, other.obj) == 0
  47. def __le__(self, other):
  48. return mycmp(self.obj, other.obj) <= 0
  49. def __ge__(self, other):
  50. return mycmp(self.obj, other.obj) >= 0
  51. def __ne__(self, other):
  52. return mycmp(self.obj, other.obj) != 0
  53. return K