diff options
Diffstat (limited to 'python/markit_red.py')
| -rw-r--r-- | python/markit_red.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/python/markit_red.py b/python/markit_red.py index a6eeaa28..914a09fa 100644 --- a/python/markit_red.py +++ b/python/markit_red.py @@ -1,20 +1,19 @@ import csv import io -import os import requests import zipfile -from pathlib import Path from lxml import etree -from utils.db import serenitas_engine +from serenitas.utils.db import serenitas_engine +from serenitas.utils.env import BASE_DIR import pandas as pd def request_payload(payload): r = requests.post("https://products.ihsmarkit.com/red/export.jsp", params=payload) res = [] - path = os.path.join(os.environ["BASE_DIR"], "Tranche_data", "RED_reports") + path = BASE_DIR / "Tranche_data" / "RED_reports" if "Delta" in payload["report"]: - path = os.path.join(path, "Deltas") + path = path / "Deltas" try: with zipfile.ZipFile(io.BytesIO(r.content)) as z: @@ -60,9 +59,7 @@ def download_report(report): def update_redcodes(fname): - with open( - os.path.join(os.environ["BASE_DIR"], "Tranche_data", "RED_reports", fname) - ) as fh: + with ("BASE_DIR" / "Tranche_data" / "RED_reports" / fname).open() as fh: et = etree.parse(fh) data_version = [] data_maturity = [] @@ -93,7 +90,7 @@ def update_redcodes(fname): def update_redindices(fname): - basedir = Path(os.environ["BASE_DIR"]) / "Tranche_data" + basedir = BASE_DIR / "Tranche_data" with open(basedir / "RED_reports" / fname) as fh: e = etree.parse(fh) root = e.getroot() |
