_base.py 961 B

1234567891011121314151617181920212223242526272829
  1. from abc import ABC
  2. from ..constants import AnnotationFlag
  3. from ..generic import NameObject, NumberObject
  4. from ..generic._data_structures import DictionaryObject
  5. class AnnotationDictionary(DictionaryObject, ABC):
  6. def __init__(self) -> None:
  7. super().__init__()
  8. from ..generic._base import NameObject # noqa: PLC0415
  9. # /Rect should not be added here as Polygon and PolyLine can automatically set it
  10. self[NameObject("/Type")] = NameObject("/Annot")
  11. # The flags were NOT added to the constructor on purpose:
  12. # We expect that most users don't want to change the default.
  13. # If they do, they can use the property. The default is 0.
  14. @property
  15. def flags(self) -> AnnotationFlag:
  16. return self.get(NameObject("/F"), AnnotationFlag(0))
  17. @flags.setter
  18. def flags(self, value: AnnotationFlag) -> None:
  19. self[NameObject("/F")] = NumberObject(value)
  20. NO_FLAGS = AnnotationFlag(0)