1+ import base64
2+ import os
13import time
24from datetime import datetime , timedelta
35
4- from libs .constants import escape_characters
6+ from libs .constants import escape_characters , file_encoding
57
68
79def convert_time_units_to_seconds (time_unit : str ) -> int :
@@ -32,12 +34,12 @@ def wait(timeout: str):
3234
3335
3436def get_link_formatted_date_time ():
35- _ampm = datetime .now ().strftime (format = "%p" ).lower ()
37+ _am_or_pm = datetime .now ().strftime (format = "%p" ).lower ()
3638 try :
3739 _dt = datetime .now ().strftime (format = "%-d %B %Y at %-I:%M" ) # Linux (Github Action)
3840 except :
3941 _dt = datetime .now ().strftime (format = "%#d %B %Y at %#I:%M" ) # Windows (Dev VDI)
40- return f"{ _dt } { _ampm } "
42+ return f"{ _dt } { _am_or_pm } "
4143
4244
4345def get_new_datetime () -> str :
@@ -62,3 +64,20 @@ def get_offset_date(offset_days: int) -> str:
6264 while _offset_date .weekday () >= 5 :
6365 _offset_date = _offset_date + timedelta (days = 1 )
6466 return _offset_date .strftime ("%Y%m%d" )
67+
68+
69+ def get_project_root () -> str :
70+ _project_root = os .path .dirname (__file__ )
71+ while os .path .basename (_project_root .lower ()) != "manage-vaccinations-in-schools-testing" :
72+ _project_root = os .path .dirname (_project_root )
73+ return _project_root
74+
75+
76+ def get_base64_encoded_string (text ):
77+ text_bytes = text .encode (file_encoding .ASCII )
78+ return base64 .b64encode (text_bytes ).decode (file_encoding .ASCII )
79+
80+
81+ def get_base64_decoded_string (encoded_string ):
82+ base64_bytes = encoded_string .encode (file_encoding .ASCII )
83+ return base64 .b64decode (base64_bytes ).decode (file_encoding .ASCII )
0 commit comments