Compare commits
No commits in common. "46b3e6ede478888a8fb35b2a7396395c94f4cb57" and "0f3b96bacac3be737148f621e8f8dba1e1b368db" have entirely different histories.
46b3e6ede4
...
0f3b96baca
|
@ -1,57 +1,28 @@
|
||||||
"""Conferences."""
|
"""Conferences."""
|
||||||
|
|
||||||
import dataclasses
|
|
||||||
import decimal
|
|
||||||
from datetime import date, datetime
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from .types import Event
|
from .types import Event
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
|
||||||
class Conference:
|
|
||||||
"""Conference."""
|
|
||||||
|
|
||||||
name: str
|
|
||||||
topic: str
|
|
||||||
location: str
|
|
||||||
start: date | datetime
|
|
||||||
end: date | datetime
|
|
||||||
venue: str | None = None
|
|
||||||
address: str | None = None
|
|
||||||
url: str | None = None
|
|
||||||
accommodation_booked: bool = False
|
|
||||||
transport_booked: bool = False
|
|
||||||
going: bool = False
|
|
||||||
registered: bool = False
|
|
||||||
speaking: bool = False
|
|
||||||
online: bool = False
|
|
||||||
price: decimal.Decimal | None = None
|
|
||||||
currency: str | None = None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def display_name(self) -> str:
|
|
||||||
"""Add location if not already in conference name."""
|
|
||||||
return (
|
|
||||||
self.name
|
|
||||||
if self.location in self.name
|
|
||||||
else f"{self.name} ({self.location})"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_list(filepath: str) -> list[Event]:
|
def get_list(filepath: str) -> list[Event]:
|
||||||
"""Read conferences from a YAML file and return a list of Event objects."""
|
"""Read conferences from a YAML file and return a list of Event objects."""
|
||||||
return [
|
with open(filepath, "r") as f:
|
||||||
Event(
|
data = yaml.safe_load(f)
|
||||||
|
|
||||||
|
events = []
|
||||||
|
for conf in data.get("conferences", []):
|
||||||
|
start_date = conf["start"]
|
||||||
|
end_date = conf["end"]
|
||||||
|
|
||||||
|
# Skip the conference if it is before the input date.
|
||||||
|
event = Event(
|
||||||
name="conference",
|
name="conference",
|
||||||
date=conf.start,
|
date=start_date,
|
||||||
end_date=conf.end,
|
end_date=end_date,
|
||||||
title=f"🎤 {conf.display_name}",
|
title=f'🎤 {conf["name"]} ({conf["location"]})',
|
||||||
url=conf.url,
|
url=conf.get("url"),
|
||||||
)
|
)
|
||||||
for conf in (
|
events.append(event)
|
||||||
Conference(**conf)
|
|
||||||
for conf in yaml.safe_load(open(filepath, "r"))["conferences"]
|
return events
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
Loading…
Reference in a new issue