my.bumble: merge from all previous android exports
This commit is contained in:
parent
b96c9f4534
commit
fd1a683d49
2 changed files with 51 additions and 32 deletions
|
@ -7,6 +7,7 @@ from dataclasses import dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Iterator, Sequence, Optional, Dict
|
from typing import Iterator, Sequence, Optional, Dict
|
||||||
|
|
||||||
|
from more_itertools import unique_everseen
|
||||||
|
|
||||||
from my.config import bumble as user_config
|
from my.config import bumble as user_config
|
||||||
|
|
||||||
|
@ -53,12 +54,19 @@ class Message(_BaseMessage):
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from ..core.error import Res
|
from ..core import Res
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from ..core.sqlite import sqlite_connect_immutable
|
from ..core.sqlite import sqlite_connect_immutable
|
||||||
def _entities() -> Iterator[Res[Union[Person, _Message]]]:
|
|
||||||
last = max(inputs()) # TODO -- need to merge multiple?
|
EntitiesRes = Res[Union[Person, _Message]]
|
||||||
with sqlite_connect_immutable(last) as db:
|
|
||||||
|
def _entities() -> Iterator[EntitiesRes]:
|
||||||
|
for db_file in inputs():
|
||||||
|
with sqlite_connect_immutable(db_file) as db:
|
||||||
|
yield from _handle_db(db)
|
||||||
|
|
||||||
|
|
||||||
|
def _handle_db(db) -> Iterator[EntitiesRes]:
|
||||||
for row in db.execute(f'SELECT user_id, user_name FROM conversation_info'):
|
for row in db.execute(f'SELECT user_id, user_name FROM conversation_info'):
|
||||||
(user_id, user_name) = row
|
(user_id, user_name) = row
|
||||||
yield Person(
|
yield Person(
|
||||||
|
@ -89,10 +97,20 @@ def _entities() -> Iterator[Res[Union[Person, _Message]]]:
|
||||||
yield e
|
yield e
|
||||||
|
|
||||||
|
|
||||||
|
def _key(r: EntitiesRes):
|
||||||
|
if isinstance(r, _Message):
|
||||||
|
if '&srv_width=' in r.text:
|
||||||
|
# ugh. seems that image URLs change all the time in the db?
|
||||||
|
# can't access them without login anyway
|
||||||
|
# so use a different key for such messages
|
||||||
|
return (r.id, r.created)
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
def messages() -> Iterator[Res[Message]]:
|
def messages() -> Iterator[Res[Message]]:
|
||||||
id2person: Dict[str, Person] = {}
|
id2person: Dict[str, Person] = {}
|
||||||
id2msg: Dict[str, Message] = {}
|
id2msg: Dict[str, Message] = {}
|
||||||
for x in _entities():
|
for x in unique_everseen(_entities(), key=_key):
|
||||||
if isinstance(x, Exception):
|
if isinstance(x, Exception):
|
||||||
yield x
|
yield x
|
||||||
continue
|
continue
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -139,6 +139,7 @@ commands =
|
||||||
-p my.coding.commits \
|
-p my.coding.commits \
|
||||||
-p my.goodreads \
|
-p my.goodreads \
|
||||||
-p my.pdfs \
|
-p my.pdfs \
|
||||||
|
-p my.bumble.android \
|
||||||
--txt-report .coverage.mypy-misc \
|
--txt-report .coverage.mypy-misc \
|
||||||
--html-report .coverage.mypy-misc \
|
--html-report .coverage.mypy-misc \
|
||||||
{posargs}
|
{posargs}
|
||||||
|
|
Loading…
Add table
Reference in a new issue