def __init__(self, caller, message="Welcome to GradeBook", questions=None): self.caller = caller self.questions = questions self.inputs = {} self.state = {} f = Figlet(font='slant') print f.renderText('GradeBook') print message try: with open("{0}/{1}_state.dat".format(m.tmp, self.caller), "r") as f: for line in f.readlines(): q, a = line.split(":") self.state[q] = a.strip() except IOError: pass
if len(sys.argv) < 3 or sys.argv[1] == "-h" or sys.argv[1] == "--help": print("Reads the file given as the first argument and lists the next [second argument] events coming up") print("NOTE: The events must be in time order.") exit() while True: output = "" now = datetime.now() f = Figlet(font="assets/shefjam.flf", width=100) output += f.renderText("Upcoming Events") #print("\nUpcoming Events:\n") events = [] with open(sys.argv[1], "r") as f: events = f.readlines(); if len(events) < 1: continue # Get the size of the pane rows, columns = os.popen('stty size', 'r').read().split() eventsShown = 0 eventsMax = int(sys.argv[2]) for i in xrange(len(events)): data = events[i].split("-") data[0] = data[0].strip() data[1] = data[1].strip() # Have to convert to a stupid datetime to make it work then strip out the time part eventTime = datetime.strptime(data[0], "%d/%m/%y %H:%M")
print("The second argument should be the game name") print( "The third argument is whether the scores should be `ascending` or `decending`" ) exit() while True: #print("\n " + sys.argv[2] + " Leader Board\n") output = "" f = Figlet() output += f.renderText("Leader Board") scores = [] with open(sys.argv[1], "r") as f: scores = f.readlines() if len(scores) < 1: continue scoreType = "number" if ":" in scores[0]: scoreType = "time" for i in xrange(len(scores)): data = scores[i].split("-") if (scoreType == "time"): # Have to convert to a stupid datetime to make it work then strip out the time part scores[i] = (datetime.strptime("1/1/17 0:" + data[0].strip(), "%d/%m/%y %H:%M:%S.%f").time(), data[1].strip())