Compare commits

...

2 commits

Author SHA1 Message Date
Edward Betts 77d2fef43a Merge branch 'main' of git.4angle.com:edward/agenda 2023-11-12 20:00:03 +01:00
Edward Betts 3d8eadb011 Add domain name renew dates
Closes: #49
2023-11-12 19:58:56 +01:00
2 changed files with 30 additions and 0 deletions

View file

@ -20,6 +20,7 @@ from . import (
birthday,
calendar,
conference,
domains,
economist,
fx,
gwr,
@ -250,6 +251,8 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml"))
events += economist.publication_dates(last_week, next_year)
events += domains.renewal_dates(my_data)
events.sort(key=operator.attrgetter("as_datetime"))
observer = sun.bristol()

27
agenda/domains.py Normal file
View file

@ -0,0 +1,27 @@
"""Accomodation."""
import csv
import os
from datetime import datetime
from .types import Event
url = "https://admin.gandi.net/domain/01578ef0-a84b-11e7-bdf3-00163e6dc886/"
def renewal_dates(data_dir: str) -> list[Event]:
"""Get domain renewal dates."""
domain_files = [
(datetime.strptime(f, "export_domains_%m_%d_%Y_%I_%M_%p.csv"), f)
for f in os.listdir(data_dir)
if f.startswith("export_domains_")
]
return [
Event(
name="domain",
title=row["fqdn"],
date=datetime.fromisoformat(row["date_registry_end_utc"][:10]).date(),
url=url + row["fqdn"],
)
for row in csv.DictReader(open(os.path.join(data_dir, max(domain_files)[1])))
]