30 lines
791 B

  1. #!/usr/bin/env python3
  2. from datetime import date
  3. from _kosmorro.i18n.utils import _, SHORT_DATE_FORMAT
  4. class UnavailableFeatureError(RuntimeError):
  5. def __init__(self, msg: str):
  6. super().__init__()
  7. self.msg = msg
  8. class OutOfRangeDateError(RuntimeError):
  9. def __init__(self, min_date: date, max_date: date):
  10. super().__init__()
  11. self.min_date = min_date
  12. self.max_date = max_date
  13. self.msg = _(
  14. "The date must be between {minimum_date} and {maximum_date}"
  15. ).format(
  16. minimum_date=min_date.strftime(SHORT_DATE_FORMAT),
  17. maximum_date=max_date.strftime(SHORT_DATE_FORMAT),
  18. )
  19. class CompileError(RuntimeError):
  20. def __init__(self, msg):
  21. super().__init__()
  22. self.msg = msg