text.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """
  2. Instances of the Text class just contain
  3. text. Their main use is as dummy-element
  4. during model development.
  5. """
  6. from typing import (
  7. Iterable,
  8. Optional
  9. )
  10. from dataladmetadatamodel.mappableobject import MappableObject
  11. from dataladmetadatamodel.mapper.reference import Reference
  12. class Text(MappableObject):
  13. def __init__(self,
  14. content: Optional[str] = None,
  15. reference: Optional[Reference] = None):
  16. assert isinstance(content, (type(None), str))
  17. assert isinstance(reference, (type(None), Reference))
  18. super().__init__(reference)
  19. self.content = content
  20. @staticmethod
  21. def get_empty_instance(reference: Optional[Reference] = None):
  22. return Text(None, reference)
  23. def get_modifiable_sub_objects_impl(self) -> Iterable[MappableObject]:
  24. return []
  25. def purge_impl(self):
  26. self.content = None
  27. def deepcopy_impl(self,
  28. new_mapper_family: Optional[str] = None,
  29. new_destination: Optional[str] = None,
  30. **kwargs) -> "Text":
  31. return Text(content=self.content, reference=self.reference)