Add support for specifying backup folder
This commit is contained in:
parent
036ea124a5
commit
0050570cfb
|
@ -65,8 +65,15 @@ def sms_soup_to_message(soup: bs4.BeautifulSoup) -> Message:
|
||||||
chat_id = ' '.join(p for p in chat_id_parts if p)
|
chat_id = ' '.join(p for p in chat_id_parts if p)
|
||||||
return Message(sent_at, sender, text, chat_id=chat_id)
|
return Message(sent_at, sender, text, chat_id=chat_id)
|
||||||
|
|
||||||
|
def select_newest_file_in_dir(path: Path) -> Path:
|
||||||
|
return min((p for p in path.iterdir() if p.suffix == '.xml' and 'sms' in p.name), key = lambda p: p.stat().st_atime_ns)
|
||||||
|
|
||||||
def parse_messages_in_backup_xml_file(path: Path) -> Iterator[Message]:
|
def parse_messages_in_backup_xml_file(path: Path) -> Iterator[Message]:
|
||||||
|
if path.is_dir():
|
||||||
|
logger.info('%s is a dir. Finding newest backup in directory', path)
|
||||||
|
path = select_newest_file_in_dir(path)
|
||||||
|
logger.info('Found: %s', path)
|
||||||
|
|
||||||
logger.info('Parsing %s', path)
|
logger.info('Parsing %s', path)
|
||||||
|
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user