Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

fb_export.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from __future__ import annotations
  2. from typing import Any, List, Set
  3. from pydantic import BaseModel
  4. from million.model.message import Message
  5. from million.model.participant import Participant
  6. class Image(BaseModel):
  7. creation_timestamp: int
  8. uri: str
  9. def __eq__(self, other: Image) -> bool:
  10. return self.creation_timestamp == other.creation_timestamp \
  11. and self.uri == other.uri
  12. class JoinableMode(BaseModel):
  13. mode: int
  14. link: str
  15. class FacebookExport(BaseModel):
  16. messages: List[Message]
  17. participants: Set[Participant]
  18. title: str
  19. is_still_participant: bool
  20. thread_path: str
  21. magic_words: Set[Any]
  22. image: Image
  23. joinable_mode: JoinableMode
  24. def merge(self, other: FacebookExport) -> None:
  25. if self == other:
  26. self.messages.extend(other.messages)
  27. self.participants.update(other.participants)
  28. self.magic_words.update(other.magic_words)
  29. def sort(self) -> None:
  30. self.messages.sort(key = lambda m: m.date_time)
  31. def __eq__(self, other: FacebookExport) -> bool:
  32. # NOTE Toughen equality conditions ?
  33. return self.title == other.title \
  34. and self.image == other.image