diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/collateral/baml_isda.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py index 10e9058e..2d39ec1a 100644 --- a/python/collateral/baml_isda.py +++ b/python/collateral/baml_isda.py @@ -64,6 +64,19 @@ paths = { } +def read_secure_message(dest, logger): + soup = BeautifulSoup(msg.body, features="lxml") + a = soup.find("a") + url = urlsplit(a["href"]) + query = parse_qs(url.query) + base_url = urlunsplit(url[:2] + ("",) * 3) + try: + download_from_secure_id(query["id"][0], query["brand"][0], dest, base_url) + except ValueError as e: + if logger: + logger.error(e) + + def download_files(em, d=None, count=20, *, fund="Serenitas", **kwargs): DATA_DIR = DAILY_DIR / fund / "BoA_reports" if fund not in paths: @@ -73,19 +86,7 @@ def download_files(em, d=None, count=20, *, fund="Serenitas", **kwargs): for msg in emails: match msg.sender.name: case "us_otc_client_valuation@baml.com" | "us_otc_client_valuation@bofa.com" if msg.body.body_type == "HTML": - soup = BeautifulSoup(msg.body, features="lxml") - if title := soup.find("title"): - if title.text == "Proofpoint Encryption": - a = soup.find("a") - url = urlsplit(a["href"]) - query = parse_qs(url.query) - base_url = urlunsplit(url[:2] + ("",) * 3) - try: - download_from_secure_id( - query["id"][0], query["brand"][0], DATA_DIR, base_url - ) - except ValueError as e: - logger.error(e) + read_secure_message(DATA_DIR, logger) case "us_otc_client_valuation@baml.com" | "us_otc_client_valuation@bofa.com" | "bank_of_america_collateral_operations@bankofamerica.com": for attach in msg.attachments: @@ -93,6 +94,11 @@ def download_files(em, d=None, count=20, *, fund="Serenitas", **kwargs): p = DATA_DIR / attach.name if not p.exists(): p.write_bytes(attach.content) + + case "mercury-reports@baml.com": + for attach in msg.attachments: + if attach.name.endswith("csv"): + p = DAILY_DIR / str(datetime.date) case _: continue |
