2024-03-05 23:57:38 -07:00
|
|
|
import re
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from typing import Union
|
|
|
|
|
|
|
|
|
|
|
|
def extract_emails(field: str):
|
|
|
|
matches = re.findall(r'([a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)', field.lower())
|
|
|
|
return tuple({str(x) for x in matches})
|
|
|
|
|
|
|
|
|
|
|
|
def unix_timestamp_since_to_imap_timestamp(unix_timestamp: Union[int, float]) -> str:
|
|
|
|
return (datetime.fromtimestamp(unix_timestamp) - timedelta(days=1)).strftime("%d-%b-%Y")
|
2024-03-06 11:36:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
def normalize_for_imap_folder(folder: str):
|
|
|
|
folder = folder.replace("'", "\'")
|
|
|
|
return f'"{folder}"'
|