def runoptions(form): if 'filename' in form: filename = form['filename'].value else: filename = '' if 'actor' in form: actor = form['actor'].value.lower() else: actor = '' if 'target' in form: target = form['target'].value.lower() else: target = '' if 'resisttype' in form: resisttype = form['resisttype'].value.lower() else: resisttype = '' if 'pdtype' in form: pdtype = form['pdtype'].value.lower() else: pdtype = '' if 'spell' in form: spell = form['spell'].value.lower() else: spell = '' print header + formhtml2 % (filename, actor, target, resisttype, pdtype, spell) if filename[-3:] == "txt": if not os.path.isfile(os.path.abspath('../'+filename[:-3]+'csv')): call(["python","logtocsv.py",os.path.abspath('../'+filename)]) filename = filename[:-3] + 'csv' data = [] pvpdata = [] thecsv = open(os.path.abspath('../'+filename)) thecsv.readline() #burns the metadata line for line in thecsv: line = re.split(',',line[:-1]) line[3] = int(line[3]) line[13] = int(line[13]) data.append(tuple(line)) #prettyprint(sbfunc.genericsort(data, actor, target, '', resisttype, pdtype, spell)) tableprettyprint(sbfunc.genericsort(data, actor, target, '', resisttype, pdtype, spell)) print '<br> <hr> <br>' pvpprint(sbfunc.pvpsort(data, 'y', 'y', 'y', 'y'))
def main(): '''Main control flow loop. Test options in the low 100's allstuff = [combat, pvpmessages, effects, leftovers] each of which is a list of tuples in it's own right. ''' filename() test = sbparser.LogParse(logfilename) allstuff = test.make_list() data = allstuff[0] pvpdata = allstuff[1] effectdata = allstuff[2] notdata = allstuff[-1] while ctr != 0: start() if ctr == 1: prettyprint(sbfunc.genericsort(data, 'y', '', '', '', '', '')) elif ctr == 2: char = str(raw_input('Damage dealer:')) print char prettyprint(sbfunc.genericsort(data, char, 'y', '', 'y', '', 'y')) elif ctr == 3: prettyprint(sbfunc.genericsort(data, '', 'y', '', '', '', '')) elif ctr == 4: char = str(raw_input('spell:')) prettyprint(sbfunc.genericsort(data, 'y', '', '', '', '', char)) elif ctr == 5: prettyprint(sbfunc.genericsort(data, '', 'y', 'y', 'y', '', 'y')) elif ctr == 6: print "Input: y or word to sort by, blank to ignore." actor = raw_input('actor:') target = raw_input('target:') resisttype = raw_input('resist type:') pdtype = raw_input('pdtype:') spell = raw_input('spell:') prettyprint(sbfunc.genericsort(data, actor, target, '', resisttype, pdtype, spell)) elif ctr == 8: main() elif ctr == 100: print 'Raw dump of data from parse:' wtf(data) elif ctr == 101: print 'Line by line dump of data from parse:' purebyline(data) elif ctr == 102: test = '' print 'lines that were not parsed:' for i in notdata: test += i print test elif ctr == 103: for i in pvpdata: print i elif ctr == 104: for i in effectdata: print i elif ctr == 105: pvpac = {} for i in pvpdata: killer = i[1] if killer in pvpac: pvpac[killer] += 1 else: pvpac[killer] = 1 for i in pvpac.items(): print i[0], "-->", i[1] elif ctr == 0: break else: print('\n\nPlease make a real choice!:\n\n') print('\n\nPlay to Crush.\n\n')