single_set_proxy.py 702 B

1234567891011121314151617181920212223
  1. from .proxy import proxy
  2. from .single_set_model import single_set_model
  3. class single_set_proxy(proxy):
  4. def set(self, target: str) -> None:
  5. self._target.content = target
  6. def get(self) -> str:
  7. return self._target.content
  8. @classmethod
  9. def _create(cls, target: type, content: str) -> proxy:
  10. if type(target) is not type:
  11. raise TypeError("Target must be an class.")
  12. if not issubclass(target, single_set_model):
  13. raise TypeError("Target must be subclass of single_set_model.")
  14. return cls(target(content = content))
  15. @classmethod
  16. def create(cls, content: str) -> proxy:
  17. raise NotImplementedError()