#!/usr/bin/env python #debbie the therapy robot import datetime # this is where to store your log files # THIS FOLDER MUST ALREADY EXIST!!!!!!!! LOCATION = "/Users/YOURUSERNAME/therapy/" # parse the input to a specific question # keep taking in input until the response is blank # this allows you to keep writing your response across multiple lines # hit enter on an empty line to finish def listen(message="??"): print message data = message + " " line = raw_input("? ") while line: data += "%s \\ " % line line = raw_input("? ") #print data return data # collect the information about an emotion def newemotion(feel = "_BLANK"): emo = "" if (feel == "_BLANK"): emo = raw_input("what are you feeling? ") else: emo = feel log = "" log = log + " ** " + listen("why are you feeling that way?") log = log + " ** " + listen("is this fair/rational?") log = log + " ** " + listen("what do you want to happen?") log = log + " ** " + listen("what can you do?") pair = [emo,log] return pair # record your different emotions def record(): emos = [] emos.append(newemotion()) while True: emnames = "" for em in emos: emnames = emnames + em[0] + ", " print "so far, you feel: " + emnames again = raw_input("enter another emotion? ") if ((again == "n") or (again == "no") or (again == "") or (again == "quit")): break else: emos.append(newemotion(again)) return emos # do one therapy session def therapy(): i = datetime.datetime.now() titl = i.strftime('%Y-%m-%d-%H-%M') titl = LOCATION + titl + ".txt" print titl print print "hello! i'm debbie!" emotions = record() f = open(titl, "a") f.write(str(emotions)) f.close() print "saved to " + titl print "bye!" # run if __name__ == '__main__': therapy()