descriptors.py 736 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) 2010-2024 openpyxl
  2. from openpyxl.descriptors.nested import (
  3. NestedMinMax
  4. )
  5. from openpyxl.descriptors import Typed
  6. from .data_source import NumFmt
  7. """
  8. Utility descriptors for the chart module.
  9. For convenience but also clarity.
  10. """
  11. class NestedGapAmount(NestedMinMax):
  12. allow_none = True
  13. min = 0
  14. max = 500
  15. class NestedOverlap(NestedMinMax):
  16. allow_none = True
  17. min = -100
  18. max = 100
  19. class NumberFormatDescriptor(Typed):
  20. """
  21. Allow direct assignment of format code
  22. """
  23. expected_type = NumFmt
  24. allow_none = True
  25. def __set__(self, instance, value):
  26. if isinstance(value, str):
  27. value = NumFmt(value)
  28. super().__set__(instance, value)