Compare commits

...

2 commits

Author SHA1 Message Date
Edward Betts f7708747b6 Remove unused code 2023-10-02 23:39:37 +01:00
Edward Betts 0f8951c979 Read data dir from config. 2023-10-02 23:38:29 +01:00
2 changed files with 4 additions and 4 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ __pycache__/
*.py[cod] *.py[cod]
__pycache__ __pycache__
.mypy_cache .mypy_cache
config

View file

@ -52,16 +52,15 @@ now = datetime.now()
today = now.date() today = now.date()
now_str = now.strftime("%Y-%m-%d_%H:%M") now_str = now.strftime("%Y-%m-%d_%H:%M")
now_utc = datetime.now(timezone.utc) now_utc = datetime.now(timezone.utc)
data_dir = "/home/edward/lib/data"
do_refresh = len(sys.argv) > 1 and sys.argv[1] == "--refresh"
next_us_presidential_election = date(2024, 11, 5) next_us_presidential_election = date(2024, 11, 5)
next_uk_general_election = date(2024, 5, 2) next_uk_general_election = date(2024, 5, 2)
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(__file__), "config")) config.read(os.path.join(os.path.dirname(__file__), "..", "config"))
access_key = config.get("exchangerate", "access_key") access_key = config.get("exchangerate", "access_key")
data_dir = config.get("data", "dir")
def get_next_timezone_transition(tz_name: str) -> datetime: def get_next_timezone_transition(tz_name: str) -> datetime:
@ -105,7 +104,7 @@ def get_gbpusd() -> Decimal:
recent = datetime.strptime(recent_filename, "%Y-%m-%d_%H:%M_GBPUSD.json") recent = datetime.strptime(recent_filename, "%Y-%m-%d_%H:%M_GBPUSD.json")
delta = now - recent delta = now - recent
if not do_refresh and existing and delta < timedelta(hours=6): if existing and delta < timedelta(hours=6):
full = os.path.join(fx_dir, recent_filename) full = os.path.join(fx_dir, recent_filename)
data = json.load(open(full), parse_float=Decimal) data = json.load(open(full), parse_float=Decimal)
if "quotes" in data and "USDGBP" in data["quotes"]: if "quotes" in data and "USDGBP" in data["quotes"]: