text.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. realm: Optional[str] = None,
  16. reference: Optional[Reference] = None):
  17. assert isinstance(content, (type(None), str))
  18. assert isinstance(reference, (type(None), Reference))
  19. super().__init__(realm, reference)
  20. self.content = content
  21. @staticmethod
  22. def get_empty_instance(realm: Optional[str] = None,
  23. reference: Optional[Reference] = None):
  24. return Text(None, realm, reference)
  25. def modifiable_sub_objects_impl(self) -> Iterable[MappableObject]:
  26. return []
  27. def purge_impl(self):
  28. self.content = None
  29. def deepcopy_impl(self,
  30. new_mapper_family: Optional[str] = None,
  31. new_destination: Optional[str] = None,
  32. **kwargs) -> "Text":
  33. copied_text = Text()
  34. copied_text.write_out(new_destination)
  35. return copied_text