From 147d84c79319d4024232065d9ecc40c0ab7b845c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 2 Oct 2023 23:27:58 +0100 Subject: [PATCH] Remove unused code --- agenda/__init__.py | 89 ---------------------------------------------- run.py | 6 ---- 2 files changed, 95 deletions(-) delete mode 100755 run.py diff --git a/agenda/__init__.py b/agenda/__init__.py index 4786763..2fd6817 100644 --- a/agenda/__init__.py +++ b/agenda/__init__.py @@ -1,5 +1,3 @@ -#!/usr/bin/python3 - import configparser import json import os @@ -20,9 +18,6 @@ import requests from agenda import spacexdata -# import trading_calendars - - warnings.simplefilter(action="ignore", category=FutureWarning) @@ -62,7 +57,6 @@ do_refresh = len(sys.argv) > 1 and sys.argv[1] == "--refresh" next_us_presidential_election = date(2024, 11, 5) next_uk_general_election = date(2024, 5, 2) -uk_lockdown_start = datetime(2020, 3, 23, 20, 30) config = configparser.ConfigParser() config.read(os.path.join(os.path.dirname(__file__), "config")) @@ -117,8 +111,6 @@ def get_gbpusd() -> Decimal: if "quotes" in data and "USDGBP" in data["quotes"]: return typing.cast(Decimal, 1 / data["quotes"]["USDGBP"]) - # url = 'https://api.exchangeratesapi.io/latest?base=GBP&symbols=USD' - # url = "https://api.exchangerate.host/latest?base=GBP&symbols=USD" url = "http://api.exchangerate.host/live" params = {"currencies": "GBP,USD", "access_key": access_key} @@ -198,17 +190,11 @@ def get_us_holiday() -> dict[str, date | str]: return {"date": next_hol[0], "title": next_hol[1]} -def days_since_lockdown_start() -> float: - """Days since the start of the first UK Covid lockdown in 2020.""" - return (now - uk_lockdown_start).total_seconds() / (3600 * 24) - - def get_data() -> dict[str, str | object]: """Get data to display on agenda dashboard.""" reply = { "now": now, "gbpusd": get_gbpusd(), - # "lockdown_days": days_since_lockdown_start(), "next_economist": next_economist(), "bank_holiday": get_next_bank_holiday(), "us_holiday": get_us_holiday(), @@ -221,78 +207,3 @@ def get_data() -> dict[str, str | object]: } return reply - - -def main(): - ocado = datetime(2021, 1, 21, 9, 30) - ocado_last_edit = datetime(2021, 1, 20, 22, 10) - - # stamp_duty_holiday = date(2021, 3, 31) - - gbpusd = get_gbpusd() - spacex = spacexdata.get_next_spacex_launch(limit=20) - - bank_holiday = get_next_bank_holiday() - - us_holiday = get_us_holiday() - - lockdown_days = (now - uk_lockdown_start).total_seconds() / (3600 * 24) - - def days_hours(when): - delta = when - (now if when.tzinfo is None else now_utc) - return f"{delta.days:>5,d} days {delta.seconds // 3600:>2.0f} hours" - - def days(when): - return " today" if when == today else f"{(when - today).days:>5,d} days" - - print() - print(f"Today is {now:%A, %-d %b %Y} GBPUSD: {gbpusd:,.3f}") - print() - print( - f" lockdown: {lockdown_days:.1f} days ({lockdown_days / 7:.2f} weeks) so far" - ) - if ocado_last_edit > now: - print( - f" Ocado last edit: {days_hours(ocado_last_edit):19s} {ocado_last_edit:%a, %d %b %H:%M}" - ) - - if ocado_last_edit > now: - print(f" Ocado delivery: {days_hours(ocado):9s} {ocado:%a, %d %b %H:%M}") - # print(f' sitar: {days_hours(sitar)} {sitar:%a, %d %b %H:%M}') - print(f" The Economist: {days(next_economist()):20s} (Thursday)") - print( - f' UK bank holiday: {days(bank_holiday["date"]):20s} {bank_holiday["date"]:%a, %d %b} {bank_holiday["title"]}' - ) - print( - f' US holiday: {days(us_holiday["date"]):20s} {us_holiday["date"]:%a, %d %b} {us_holiday["title"]}' - ) - # print(f'stamp duty holiday: {days(stamp_duty_holiday):20s} {stamp_duty_holiday:%a, %d %b}') - print( - f" general election: {days(next_uk_general_election):20s} {next_uk_general_election:%a, %d %b %Y}" - ) - print( - f" US pres. election: {days(next_us_presidential_election):20s} {next_us_presidential_election:%a, %d %b %Y}" - ) - # print(f' Amazon prime: {days(amazon_prime):18s} {amazon_prime:%a, %d %b}') - # print(f'extend transition: {days_hours(extend_transition_deadline)} {extend_transition_deadline:%a, %d %b %H:%M} deadline to extend the transition period ') - - print() - - print(" SpaceX launchs") - for launch in spacex: - if launch["when"] > now_utc + timedelta(days=120): - continue - if launch["date_precision"] == "day": - print( - f' {days(launch["when"].date()):>8s} {launch["when"]:%a, %d %b} {launch["name"]} ({launch["rocket"]}, {" + ".join(launch["payloads"])})', - launch["date_precision"], - ) - else: - print( - f' {days_hours(launch["when"])} {launch["when"]:%a, %d %b %H:%M} {launch["name"]} ({launch["rocket"]}, {" + ".join(launch["payloads"])})', - launch["date_precision"] or "", - ) - - print() - for line in stock_markets(): - print(line) diff --git a/run.py b/run.py deleted file mode 100755 index b283063..0000000 --- a/run.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3 - -from agenda import main - -if __name__ == "__main__": - main()