Enhance conference validation and add MAX_CONF_DAYS
- Add checks for conference start and end dates. - Set maximum conference duration to 20 days. Closes: #182
This commit is contained in:
parent
34d1ee3b30
commit
ef624f83dd
|
@ -6,8 +6,11 @@ from datetime import date, datetime
|
|||
|
||||
import yaml
|
||||
|
||||
from . import utils
|
||||
from .event import Event
|
||||
|
||||
MAX_CONF_DAYS = 20
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Conference:
|
||||
|
@ -55,6 +58,9 @@ def get_list(filepath: str) -> list[Event]:
|
|||
"""Read conferences from a YAML file and return a list of Event objects."""
|
||||
events: list[Event] = []
|
||||
for conf in (Conference(**conf) for conf in yaml.safe_load(open(filepath, "r"))):
|
||||
assert conf.start <= conf.end
|
||||
duration = (utils.as_date(conf.end) - utils.as_date(conf.start)).days
|
||||
assert duration < MAX_CONF_DAYS
|
||||
event = Event(
|
||||
name="conference",
|
||||
date=conf.start,
|
||||
|
|
Loading…
Reference in a new issue