diff options
| -rw-r--r-- | python/collateral/baml_isda.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py index 5ddfd8da..b2faa1a7 100644 --- a/python/collateral/baml_isda.py +++ b/python/collateral/baml_isda.py @@ -75,17 +75,26 @@ def download_files(em, d=None, count=20, *, fund="Serenitas", **kwargs): or msg.sender.name == "us_otc_client_valuation@bofa.com" ): 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], DATA_DIR, base_url - ) - except ValueError as e: - logger.error(e) - continue + 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) + continue + else: + for attach in msg.attachments: + if attach.name.endswith("xls") or attach.name.endswith("pdf"): + p = DATA_DIR / attach.name + if not p.exists(): + p.write_bytes(attach.content) + if msg.sender.name == "bank_of_america_collateral_operations@bankofamerica.com": for attach in msg.attachments: if attach.name.endswith("xls"): |
