diff options
Diffstat (limited to 'python/report_ops/custodians.py')
| -rw-r--r-- | python/report_ops/custodians.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py index 2f9bf6fd..c1eb39c8 100644 --- a/python/report_ops/custodians.py +++ b/python/report_ops/custodians.py @@ -105,7 +105,7 @@ def upload_to_custodian(account, trade_date, upload): _fund_folder_mapping = { - "SERCGMAST": "NYOps", + "SERCGMAST": "NYops", "BOWDST": "BowdoinOps", "ISOSEL": "SeleneOps", } @@ -117,7 +117,7 @@ def download_nt_reports(date, fund, em): ): for attach in msg.attachments: message_time = attach.last_modified_time.replace( - tzinfo=cls.em._account.default_timezone + tzinfo=em._account.default_timezone ) if attach.name == "Attachment1.pgp": dest = get_dir(message_time.date(), archived=False) @@ -127,14 +127,14 @@ def download_nt_reports(date, fund, em): fp.read(), passphrase="Serenitas1" ) if "custodian" in verify_result.file_name: - fname = "NT_WIRE_{fund}" - elif "cash" in verify_result.filename: - fname = "NT_CASH_{fund}" + fname = f"NT_WIRE_{fund}" + elif "Cash" in verify_result.file_name: + fname = f"NT_CASH_{fund}" else: - pass + print(f"NT file not recognized:{verify_result.file_name}") p = dest / f"{fname}_{message_time:%Y%m%d%H%M}.csv" if not p.exists(): - with open(dest, "w") as csvFile: + with open(p, "w") as csvFile: text = plaintext.decode("utf-8").replace("\t", ",") csvFile.write(text) @@ -147,9 +147,9 @@ def download_umb_reports(date, fund, em): end_date=date, ): for attach in msg.attachments: - if fname.endswith("xlsx"): + if attach.name.endswith("xlsx"): ts = attach.last_modified_time.replace( - tzinfo=cls.em._account.default_timezone + tzinfo=em._account.default_timezone ) dest = get_dir(date, archived=False) dest.mkdir(exist_ok=True, parents=True) @@ -164,7 +164,7 @@ def download_umb_reports(date, fund, em): def download_bny_reports(date, fund, em): - for msg in cls.em.get_msgs( + for msg in em.get_msgs( 20, path=[_fund_folder_mapping[fund], "Reports"], subject__startswith="Document(s) from Reporting", @@ -175,7 +175,7 @@ def download_bny_reports(date, fund, em): for attach in msg.attachments: fname = attach.name if fname.endswith("csv"): - file_type, timestamp = fname.split("_") + file_type, timestamp = fname.rsplit("_", 1) date = dp.parse(timestamp.removesuffix(".csv")).date() p = DAILY_DIR / str(date) / "Reports" / fname if not p.parent.exists(): @@ -191,7 +191,6 @@ def download_scotia_reports(date, fund, **kwargs): ElementNotInteractableException, TimeoutException, ) as e: - print(e) raise ValueError(f"No Scotia report {fund}:{date}") |
