Validate conference date ranges
This commit is contained in:
parent
7ec36a5e80
commit
14f5baf77c
1 changed files with 19 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ import agenda.data
|
|||
import agenda.travel
|
||||
import agenda.trip
|
||||
import agenda.types
|
||||
import agenda.utils
|
||||
|
||||
config = __import__("config.default", fromlist=[""])
|
||||
data_dir = config.PERSONAL_DATA
|
||||
|
|
@ -267,6 +268,23 @@ def check_trains() -> None:
|
|||
print(len(trains), "trains")
|
||||
|
||||
|
||||
def check_conference_dates(conf: agenda.conference.Conference) -> None:
|
||||
"""Check conference start/end range."""
|
||||
if normalize_datetime(conf.start) > normalize_datetime(conf.end):
|
||||
pprint(conf)
|
||||
print(f"conference {conf.name!r} ends before it starts")
|
||||
sys.exit(-1)
|
||||
|
||||
duration = (agenda.utils.as_date(conf.end) - agenda.utils.as_date(conf.start)).days
|
||||
if duration >= agenda.conference.MAX_CONF_DAYS:
|
||||
pprint(conf)
|
||||
print(
|
||||
f"conference {conf.name!r} is {duration} days; "
|
||||
+ f"maximum is {agenda.conference.MAX_CONF_DAYS - 1}"
|
||||
)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def check_conferences() -> None:
|
||||
"""Check conferences and ensure they are in chronological order."""
|
||||
filepath = os.path.join(data_dir, "conferences.yaml")
|
||||
|
|
@ -285,6 +303,7 @@ def check_conferences() -> None:
|
|||
sys.exit(-1)
|
||||
|
||||
check_country_code(conf_data, "conference", required=False)
|
||||
check_conference_dates(conf)
|
||||
|
||||
current_start = normalize_datetime(conf_data["start"])
|
||||
if prev_start and current_start < prev_start:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue