Skip to content

Instantly share code, notes, and snippets.

@bhpayne
Created April 14, 2021 12:00
Show Gist options
  • Save bhpayne/08a50df10cc218f9857d60bfd232f598 to your computer and use it in GitHub Desktop.
Save bhpayne/08a50df10cc218f9857d60bfd232f598 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from datetime import datetime
import os
"""
Much of the typical professional communication follows a script.
Therefore, we can use a script to generate the content.
This script implements a decision tree that gets presented
to the user as a sequence of prompts. The output of the
decision tree is a snippet of text that can be used to communicate
with coworkers.
https://en.wikipedia.org/wiki/Mad_Libs
"""
def clear():
"""remove content on screen
https://www.geeksforgeeks.org/clear-screen-python/
"""
# for windows
if os.name == 'nt':
_ = os.system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = os.system('clear')
def triage_form(prompt_dict: dict, default_int: int) -> int:
"""
Args:
prompt_dict
default_int
Returns:
selected_value
"""
# every prompt will have an option to exit the menu
prompt_dict[0] = " terminate this program"
while True:
for index, string_option in prompt_dict.items():
print(str(index) + ": " + string_option)
val = input("\nSelect [default is "+str(default_int)+"]: ")
if val=="":
val=default_int
try:
selected_value = int(val)
except ValueError:
print("\nERROR: invalid selection, try again\n")
if selected_value==0:
print("Thank you for using madlibs status report\n")
exit()
if selected_value in prompt_dict.keys():
clear()
return selected_value
else:
print("\nERROR: not a valid choice, try again\n")
clear()
def start_new_email() -> str:
"""
Returns
str_to_print
"""
email_recipient_name = input("Name of person to send email to: ")
str_to_print = "Hello "+email_recipient_name+",\n\n"
clear()
return str_to_print
return str_to_print
def end_email_and_send(str_to_print: str) -> None:
"""
Args:
str_to_print
"""
my_name = input("My first name is: ")
str_to_print+="\n\nKindly,\n\n"+my_name+"\n"
clear()
print(str_to_print)
print("\n Instructions: paste the above content into an email and send\n")
_ = input("Press any key to continue: ")
return
if __name__ == '__main__':
str_to_print = ""
while True:
clear()
print(" I want to")
prompt_dict = {1: "create an activity report for a wiki task page",
2: "create a weekly status report",
3: "respond to a question",
4: "ask for help"}
triage_selected_value = triage_form(prompt_dict, 1)
# print("\nTRACE: "+my_name + " selected to " + prompt_dict[triage_selected_value]+"\n")
if triage_selected_value==1: #"create an activity report for a wiki task page"
my_USERID = input("My USERID: ")
print("\n "+prompt_dict[1])
prompt_dict = {1: "I worked alone",
2: "I collaborated with someone"}
solo_collab_selected_value = triage_form(prompt_dict, 2)
str_to_print += datetime.today().strftime('%Y-%m-%d')
str_to_print += " [[User:"+my_USERID+"]]"
if solo_collab_selected_value==1:
str_to_print += " worked solo on "
elif solo_collab_selected_value==2:
str_to_print += " collaborated with "
collab_USERID = input("USERID of Collaborator: ")
str_to_print += "[[User:"+collab_USERID+"]] on "
else:
raise Exception("misconfiguration")
print(str_to_print+"\n")
prompt_dict = {1: "debugging",
2: "creating",
3: "designing",
4: "reading",
5: "watching"}
debug_create_selected_value = triage_form(prompt_dict, 1)
str_to_print += prompt_dict[debug_create_selected_value]
if debug_create_selected_value==1: # debugging
print(str_to_print+"\n")
prompt_dict = {1: " previously reported issue",
2: " previously unknown issue"}
debug_selected_value = triage_form(prompt_dict, 2)
str_to_print += prompt_dict[debug_selected_value]
if debug_selected_value==1:
str_to_print += input("Link to known issue: ")
elif debug_selected_value==2:
str_to_print += input("Link to new issue: ")
else:
raise Exception("misconfiguration")
str_to_print += ". The specific code that was debugged is located at "
str_to_print += input("location of file(s): ")
elif debug_create_selected_value==2: # creating
print(str_to_print+"\n")
prompt_dict = {1: " new documentation",
2: " new software"}
create_selected_value = triage_form(prompt_dict, 2)
str_to_print += prompt_dict[create_selected_value]
str_to_print += " which is located at "
str_to_print += input("location of files: ")
elif debug_create_selected_value==3: # designing
print(str_to_print+"\n")
prompt_dict = {1: " a better approach to ",
2: " a ground-breaking approach to "}
design_selected_value = triage_form(prompt_dict, 2)
str_to_print += prompt_dict[design_selected_value]
str_to_print += input("description of scope and intent: ")
elif debug_create_selected_value==4: # reading
print(str_to_print+"\n")
prompt_dict = {1: " a internet article",
2: " a journal article",
3: " soure code"}
read_selected_value = triage_form(prompt_dict, 2)
str_to_print += prompt_dict[read_selected_value]
if read_selected_value==1 or read_selected_value==2:
title = input("title: ")
URL = input("URL or address: ")
str_to_print += "title="+title+"; "
str_to_print += "address="+URL+"; "
elif debug_create_selected_value==5: # watching
print(str_to_print+"\n")
prompt_dict = {1: "a youtube video"}
video_selected_value = triage_form(prompt_dict, 2)
str_to_print += prompt_dict[video_selected_value]
str_to_print += " which is located at "
str_to_print += input("URL: ")
else:
raise Exception("misconfiguration")
clear()
print("\n"+str_to_print+"\n")
print("\n Instructions: paste this activity description on the wiki task page\n")
_ = input("Press any key to continue: ")
elif triage_selected_value==2: # "create a weekly status report"
print("\n "+prompt_dict[2])
str_to_print = start_new_email()
worked_on_another_task=True
while worked_on_another_task:
prompt_dict = {1: "I worked on a task",
2: "no more tasks to report on"}
task_loop_selected_value = triage_form(prompt_dict, 1)
if task_loop_selected_value==2:
worked_on_another_task = False
break
prompt_dict = {1: "I made progress on task",
2: "I am blocked on task"}
progress_blocked__selected_value = triage_form(prompt_dict, 1)
link_to_task = input("link to task: ")
if progress_blocked__selected_value==1: # progress
str_to_print += "Last week I made progress on " + link_to_task
elif progress_blocked__selected_value==2: # blocked
str_to_print += "I am blocked on: " + link_to_task
else:
raise Exception("misconfiguration")
str_to_print += "and this week I plan to work on "
work_on_another_task=True
while work_on_another_task:
link_to_task = input("link to task: ")
prompt_dict = {1: "solo",
2: "collborate with"}
solo_collab_selected_value = triage_form(prompt_dict, 1)
str_to_print += prompt_dict[solo_collab_selected_value]
prompt_dict = {1: "specify another task",
2: "done with specifying future tasks"}
more_tasks = triage_form(prompt_dict, 1)
if more_tasks==2:
work_on_another_task=False
break
end_email_and_send(str_to_print)
elif triage_selected_value==3: # "respond to a question",
print("\n "+prompt_dict[3])
str_to_print = start_new_email()
str_to_print += "Thank you for your question. I "
prompt_dict = {1: "don't understand what you are asking for. What is the context?",
2: "don't understand what you are asking for. The words you are using are unclear.",
3: "understand what you are seeking.",
4: "will need time to come up with an answer.",
5: "don't know the answer."}
question_selected_value = triage_form(prompt_dict, 1)
str_to_print += prompt_dict[question_selected_value]
if question_selected_value==2:
print(str_to_print+"\n")
str_to_print += "The words I need clarifcation on are"
str_to_print += input("word(s): ")
elif question_selected_value==4:
print(str_to_print+"\n")
str_to_print += "I will reply to you by "
str_to_print += input("YYYYMMDD: ")
end_email_and_send(str_to_print)
elif triage_selected_value==4: # "ask for help"}
print("\n "+prompt_dict[4])
str_to_print = start_new_email()
str_to_print += "I am seeking your help with "
print(str_to_print+"\n")
prompt_dict = {1: "a task I am blocked on: ",
2: "how to plan next steps for an existing task. ",
3: "an idea for a new task. ",
4: "a bug I encountered in task ",
5: "software I want. ",
6: "a design question. ",
7: "a problem with my coworker. ",
8: "how this task fits into the team objectives. ",
9: "understanding what the intent of ticket "}
help_selected_value = triage_form(prompt_dict, 1)
str_to_print += prompt_dict[help_selected_value]
if (help_selected_value==1 or
help_selected_value==2 or
help_selected_value==4 or
help_selected_value==8 or
help_selected_value==9):
print(str_to_print+"\n")
str_to_print += input("URL for ticket: ")
print(str_to_print+"\n")
prompt_dict = {1: "Could you stop by my desk when you have time?",
2: "Could we set up a one-on-one discussion?",
3: "Could you reply via email?"}
response_action_selected_value = triage_form(prompt_dict, 1)
str_to_print += prompt_dict[response_action_selected_value]
if response_action_selected_value==2:
print(str_to_print+"\n")
str_to_print += "I looked at your calendar and see that you appear to be available on "
day = input("Date person has availability on their Outlook calendar: ")
str_to_print += day + " at "
time = input("Time window that person has availability on their Outlook calendar:")
str_to_print += time
end_email_and_send(str_to_print)
else:
raise Exception("misconfiguration")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment