New build_url() method.
This commit is contained in:
parent
56645e3ff8
commit
befdfd8bb8
17
check.py
17
check.py
|
@ -186,21 +186,24 @@ class Conference:
|
||||||
@property
|
@property
|
||||||
def url(self) -> str:
|
def url(self) -> str:
|
||||||
"""Conference URL."""
|
"""Conference URL."""
|
||||||
return self.src_url.format(year=self.year)
|
return self.build_url(year=self.year)
|
||||||
|
|
||||||
|
def build_url(self, year: int) -> str:
|
||||||
|
"""Build conference URL."""
|
||||||
|
return self.src_url.format(year=year, two_digit_year=year % 2000)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def past_url(self) -> str:
|
def past_url(self) -> str:
|
||||||
"""URL for previous year."""
|
"""URL for previous year."""
|
||||||
return self.src_url.format(year=self.year - 1)
|
return self.build_url(year=self.year - 1)
|
||||||
|
|
||||||
def check(self) -> tuple[bool, str, str | None]:
|
def check(self) -> tuple[bool, str, str | None]:
|
||||||
"""Check if conference is live."""
|
"""Check if conference is live."""
|
||||||
no_dot = {"bsideskbh.dk", "pif.camp"}
|
no_dot = {"bsideskbh.dk", "pif.camp"}
|
||||||
session = (
|
url = self.url
|
||||||
s if all(hostname not in self.url for hostname in no_dot) else s_no_dot
|
session = s if all(hostname not in url for hostname in no_dot) else s_no_dot
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
r = session.get(self.url)
|
r = session.get(url)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
return (False, "connection refused", None)
|
return (False, "connection refused", None)
|
||||||
|
|
||||||
|
@ -229,7 +232,7 @@ class Conference:
|
||||||
|
|
||||||
def check_web_site(self) -> bool:
|
def check_web_site(self) -> bool:
|
||||||
"""Check if an individual web site is live."""
|
"""Check if an individual web site is live."""
|
||||||
assert "{year}" in self.src_url
|
assert "{year}" in self.src_url or "{two_digit_year}" in self.src_url
|
||||||
live, msg, redirect_to_url = self.check()
|
live, msg, redirect_to_url = self.check()
|
||||||
if not live:
|
if not live:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue