text_part_time.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from collections.abc import Mapping
  2. from typing import Any, TypeVar, Union
  3. from attrs import define as _attrs_define
  4. from attrs import field as _attrs_field
  5. from ..types import UNSET, Unset
  6. T = TypeVar("T", bound="TextPartTime")
  7. @_attrs_define
  8. class TextPartTime:
  9. """
  10. Attributes:
  11. start (float):
  12. end (Union[Unset, float]):
  13. """
  14. start: float
  15. end: Union[Unset, float] = UNSET
  16. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  17. def to_dict(self) -> dict[str, Any]:
  18. start = self.start
  19. end = self.end
  20. field_dict: dict[str, Any] = {}
  21. field_dict.update(self.additional_properties)
  22. field_dict.update(
  23. {
  24. "start": start,
  25. }
  26. )
  27. if end is not UNSET:
  28. field_dict["end"] = end
  29. return field_dict
  30. @classmethod
  31. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  32. d = dict(src_dict)
  33. start = d.pop("start")
  34. end = d.pop("end", UNSET)
  35. text_part_time = cls(
  36. start=start,
  37. end=end,
  38. )
  39. text_part_time.additional_properties = d
  40. return text_part_time
  41. @property
  42. def additional_keys(self) -> list[str]:
  43. return list(self.additional_properties.keys())
  44. def __getitem__(self, key: str) -> Any:
  45. return self.additional_properties[key]
  46. def __setitem__(self, key: str, value: Any) -> None:
  47. self.additional_properties[key] = value
  48. def __delitem__(self, key: str) -> None:
  49. del self.additional_properties[key]
  50. def __contains__(self, key: str) -> bool:
  51. return key in self.additional_properties