aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/collateral/baml_isda.py46
1 files changed, 20 insertions, 26 deletions
diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py
index b2faa1a7..10e9058e 100644
--- a/python/collateral/baml_isda.py
+++ b/python/collateral/baml_isda.py
@@ -69,38 +69,32 @@ def download_files(em, d=None, count=20, *, fund="Serenitas", **kwargs):
if fund not in paths:
return
emails = em.get_msgs(path=paths[fund], count=count)
+
for msg in emails:
- if (
- msg.sender.name == "us_otc_client_valuation@baml.com"
- or msg.sender.name == "us_otc_client_valuation@bofa.com"
- ):
- 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)
- continue
- else:
+ 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)
+
+ 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:
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"):
- p = DATA_DIR / attach.name
- if not p.exists():
- p.write_bytes(attach.content)
+ case _:
+ continue
def load_excel_old(fname):