db_helper addition: Add functionality to format list of breaks
This commit is contained in:
@@ -184,6 +184,58 @@ class DBHelper():
|
||||
return
|
||||
|
||||
|
||||
def formatted_list_of_breaks(self, breaks: list) -> str:
|
||||
"""Format the python list of breaks.
|
||||
|
||||
Args:
|
||||
breaks (list): The list that needs to be formatted
|
||||
|
||||
Returns:
|
||||
str: the list as an outputtable string
|
||||
"""
|
||||
length = len(breaks)
|
||||
output: str = ''
|
||||
|
||||
if length == 0:
|
||||
return 'No breaks have been scheduled!'
|
||||
|
||||
for entry in breaks:
|
||||
|
||||
for item in range(4):
|
||||
if item == 0:
|
||||
output += f"Break submitted by: {self.return_char_name(entry[0])}"
|
||||
|
||||
if item == 1:
|
||||
# is_range boolean
|
||||
if entry[1] == True:
|
||||
# if it is a range, format as a range
|
||||
output += f' • Break range: {entry[2]} until... '
|
||||
|
||||
else:
|
||||
# if it is not a range, format as a single date
|
||||
output += f' • Break date: {entry[2]}'
|
||||
|
||||
if item == 2:
|
||||
if entry[1] == True:
|
||||
output += f'{entry[3]}.\n'
|
||||
else:
|
||||
output += '\n'
|
||||
output += "END OF MESSAGE"
|
||||
return output
|
||||
|
||||
|
||||
def format_list_of_breaks(self, breaks: list) -> str:
|
||||
"""Format the list of breaks
|
||||
|
||||
Args:
|
||||
breaks (list): The list that needs to be formatted
|
||||
|
||||
Returns:
|
||||
str: The formatted list to the bot_core or bot_aux
|
||||
"""
|
||||
return self.formatted_list_of_breaks(breaks=breaks)
|
||||
|
||||
|
||||
def formatted_list_of_callouts(self, callouts: list) -> str:
|
||||
"""Format the python list of callouts.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user