diff --git a/libpurple_to_markdown/__main__.py b/libpurple_to_markdown/__main__.py index da90b7a..eb2317d 100644 --- a/libpurple_to_markdown/__main__.py +++ b/libpurple_to_markdown/__main__.py @@ -109,8 +109,7 @@ def main(): for chat_id, messages_in_chat_original in messages_by_chat_id.items(): messages_in_chat = merge_adjacent_messages(messages_in_chat_original) if len(messages_in_chat) <= 2: - logger.info( - ' "%s": Skipped due to too few messages', chat_id) + logger.info(' "%s": Skipped due to too few messages', chat_id) continue messages_by_period = group_messages_by_period(messages_in_chat) @@ -123,8 +122,10 @@ def main(): ) for period_key, messages in messages_by_period.items(): - file_escaped_chat_id = chat_id.replace(' ','-') - output_file = args.output / chat_id / f'{file_escaped_chat_id}-{period_key}.md' + file_escaped_chat_id = chat_id.replace(' ', '-') + output_file = ( + args.output / chat_id / f'{file_escaped_chat_id}-{period_key}.md' + ) output_file.parent.mkdir(exist_ok=True) logger.info('Writing % 5d messages to %s', len(messages), output_file) with open(output_file, 'w') as f: diff --git a/libpurple_to_markdown/synctech_sms.py b/libpurple_to_markdown/synctech_sms.py index 1b49ad5..aae2f22 100644 --- a/libpurple_to_markdown/synctech_sms.py +++ b/libpurple_to_markdown/synctech_sms.py @@ -17,6 +17,7 @@ from .data import MYSELF, Message logger = logging.getLogger(__name__) + def is_named_number(num: str) -> str: try: int(num.removeprefix('+').replace(' ', '')) @@ -24,6 +25,7 @@ def is_named_number(num: str) -> str: except ValueError: return True + def normalize_phone_number(num: str) -> str: if is_named_number(num): return num diff --git a/test/test_synctech_sms.py b/test/test_synctech_sms.py index fc98d02..39d1e6e 100644 --- a/test/test_synctech_sms.py +++ b/test/test_synctech_sms.py @@ -10,5 +10,6 @@ def test_normalize_phone_number(): assert synctech_sms.normalize_phone_number('441234567890') == '+441234567890' assert synctech_sms.normalize_phone_number('004712345678') == '+4712345678' + def test_dont_normalize_weird(): assert synctech_sms.normalize_phone_number('Midttrafik') == 'Midttrafik'