Ruff
This commit is contained in:
parent
8cec980d31
commit
b0c81bc95b
|
@ -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)
|
||||
|
@ -124,7 +123,9 @@ 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'
|
||||
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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user