28 lines
769 B
Python
28 lines
769 B
Python
"""Domain renewal dates."""
|
|
|
|
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])))
|
|
]
|