diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/intex/intex_scenarios.py | 2 | ||||
| -rw-r--r-- | python/markit/cds.py | 8 | ||||
| -rw-r--r-- | python/task_server/insert_tranche_quotes.py | 11 |
3 files changed, 10 insertions, 11 deletions
diff --git a/python/intex/intex_scenarios.py b/python/intex/intex_scenarios.py index 97d6dc8d..509ed024 100644 --- a/python/intex/intex_scenarios.py +++ b/python/intex/intex_scenarios.py @@ -10,7 +10,7 @@ import yaml from csv import reader from pathlib import Path -BASE_DIR = Path(os.environ["BASE_DIR"]) # we do not want to depend on serenitas.utils +BASE_DIR = Path(os.environ["SERENITAS_BASE_DIR"]) # we do not want to depend on serenitas.utils logger = logging.getLogger(__name__) diff --git a/python/markit/cds.py b/python/markit/cds.py index 27b6ce0d..958c53c4 100644 --- a/python/markit/cds.py +++ b/python/markit/cds.py @@ -59,11 +59,9 @@ def download_composite_data( if f.endswith("csv"):
path = z.extract(
f,
- path=os.path.join(
- os.environ["BASE_DIR"],
- "Tranche_data",
- "Composite_reports",
- ),
+ path=BASE_DIR /
+ "Tranche_data" /
+ "Composite_reports"
)
if historical:
os.utime(path, (ts, ts))
diff --git a/python/task_server/insert_tranche_quotes.py b/python/task_server/insert_tranche_quotes.py index 8421e5e5..7c3a257b 100644 --- a/python/task_server/insert_tranche_quotes.py +++ b/python/task_server/insert_tranche_quotes.py @@ -1,6 +1,6 @@ from sqlalchemy import Table, create_engine, MetaData from sqlalchemy.exc import IntegrityError, DataError, SAWarning -import os +from serenitas.utils.env import BASE_DIR import csv import datetime import logging @@ -39,10 +39,10 @@ runningdict2 = {0: 500, 3:500, 7:500, 10:100, 15:100, 30:100} def insert_quotes(year=2016, quote_dir=None): if not quote_dir: - quote_dir = os.path.join(os.environ['BASE_DIR'], 'Tranche_data', 'Quotes') - quotefiles = [f for f in os.listdir(quote_dir) if f.endswith('csv')] + quote_dir = BASE_DIR / 'Tranche_data' / 'Quotes' + quotefiles = [f for f in quote_dir.iterdir() if f.stem == ".csv"] for quotefile in quotefiles: - with open(os.path.join(quote_dir, quotefile)) as fh: + with quotefile.open() as fh: reader = csv.DictReader(fh) data = [] for csvdict in reader: @@ -204,7 +204,8 @@ def insert_quotes(year=2016, quote_dir=None): logging.debug(e.orig) t.rollback() - os.unlink(os.path.join(quote_dir, quotefile)) + quotefile.unlink() + if __name__ == "__main__": insert_quotes() |
