Added docstrings

This commit is contained in:
Stanislas Jouffroy 2024-02-18 09:16:11 +01:00
parent 5434a74d0f
commit ccd019eb4c
4 changed files with 174 additions and 21 deletions

View file

@ -13,6 +13,12 @@ load_dotenv()
def get_club() -> Club:
"""
Read the environment variables related to the current club
and build the Club object
:return: the club
"""
club_url = os.environ.get("CLUB_URL")
court_ids_tmp = os.environ.get("COURT_IDS") or ""
court_ids = (
@ -34,6 +40,12 @@ def get_club() -> Club:
def get_booking_filter() -> BookingFilter:
"""
Read the environment variables related to the current booking filter
and build the BookingFilter object
:return: the club
"""
sport_id_tmp = os.environ.get("SPORT_ID")
sport_id = int(sport_id_tmp) if sport_id_tmp else None
date_time_tmp = os.environ.get("DATE_TIME")
@ -42,12 +54,24 @@ def get_booking_filter() -> BookingFilter:
def get_user() -> User:
"""
Read the environment variables related to the current user
and build the User object
:return: the club
"""
login = os.environ.get("LOGIN")
password = os.environ.get("PASSWORD")
return User(login=login, password=password)
def get_post_headers(platform_id: str) -> dict:
"""
Get the headers for the POST endpoint related to a specific booking platform
:param platform_id: the platform to which the headers apply
:return: the headers as a dictionary
"""
root_path = Path(__file__).parent
headers_file = Path(root_path, "resources", platform_id, "post-headers.json")
with headers_file.open(mode="r", encoding="utf-8") as f:
@ -57,6 +81,9 @@ def get_post_headers(platform_id: str) -> dict:
def init_log_config():
"""
Read the logging.yaml file to initialize the logging configuration
"""
root_dir = os.path.realpath(os.path.dirname(__file__))
logging_file = root_dir + "/logging.yaml"