def wikiLSIGSrow(ts, prefix): gfga = "%d/%d" % (ts.goalsFor, ts.goalsAgainst) if prefix: return "| %3d | %-50s | %5s | %-5s | %4d | %5d |" % ( counter.next(), ts.teamWiki(), ts.group.upper(), gfga, ts.goalsDiff, ts.points, ) else: return "| %-50s | %5s | %-5s | %4d | %5d |" % ( ts.teamWiki(), ts.group.upper(), gfga, ts.goalsDiff, ts.points, ) def wikiLSIGS(num=10, prefix=False): standings = unmarshal("parsed/gss.pkl", maxint) print "\n\n==== Lowest score in group stage ====\n".encode("utf-8") print wikiLSIGSheader(prefix).encode("utf-8") for row in list(reversed(teamSorted(standings)))[:num]: print wikiLSIGSrow(row, prefix).encode("utf-8") optfunc.main(wikiLSIGS)
def main(): #~ optfunc.run(convert_rgb565) optfunc.main([convert_rgb565,download])
from globals import MatchStat, unmarshalMatches, counter from operator import itemgetter from optfunc import optfunc def wikiMYCIGSheader(prefix): if prefix: return '^ # ^ %-50s ^ Yellow ^ 2Y=R ^ Direct Red ^ Weighted Total ^' % ('Team') else: return '^ %-50s ^ Yellow ^ 2Y=R ^ Direct Red ^ Weighted Total ^' % ('Team') def wikiMYCIGSrow(team, yellow, yyr, red, total, prefix): _total = '**%d**' % (total) if prefix: return '| %3d | %-50s | %8d | %6d | %12s | %16s |' % (counter.next(),team,yellow,yyr,red,_total) else: return '| %-50s | %8d | %6d | %12s | %16s |' % (team,yellow,yyr,red,_total) def wikiMYCIGS(num=10,prefix=False): cards=dict() for ms in unmarshalMatches('parsed/match%02d.pkl',48): if ms.hasResults: for team in [ms.homeWiki(), ms.awayWiki()]: if team not in cards: cards[team] = (0,0,0,0) cards[ms.homeWiki()] = tuple( old+new for old,new in zip(cards[ms.homeWiki()],ms.homeCards) ) cards[ms.awayWiki()] = tuple( old+new for old,new in zip(cards[ms.awayWiki()],ms.awayCards) ) print '\n\n==== Most yellow cards in group stage ====\n'.encode('utf-8') print wikiMYCIGSheader(prefix).encode('utf-8') for (team,[yellow,yyr,red,total]) in list(reversed(sorted(cards.items(),key=lambda f:f[1][3])))[:num]: print wikiMYCIGSrow(team,yellow,yyr,red,total,prefix).encode('utf-8') optfunc.main(wikiMYCIGS)
session.commit() #~ print unicode(msg.value, errors='replace') #~ print msg.value print "added: %s" % ", ".join(map(lambda x: x.name, added_persons)) def for_ever(): while True: try: user_input = raw_input("ISBN:") except KeyboardInterrupt: print "\nbye..." break print user_input if user_input == 'exit': break if not user_input: continue try: one(user_input) os.system('play -q audio/success.wav') except: os.system('play -q audio/failure.wav') if __name__ == '__main__': #~ optfunc.run(find) optfunc.main([for_ever,one])
#!/usr/bin/python from globals import MatchStat, unmarshalMatches, counter from operator import itemgetter from optfunc import optfunc def wikiFGheader(prefix): if prefix: return '^ # ^ %-50s ^ Minute ^' % ('Team') else: return '^ %-50s ^ Minute ^' % ('Team') def wikiFGrow(team, minute,prefix): if prefix: return "| %3d | %-50s | %7d' |" % (counter.next(),team,minute) else: return "| %-50s | %7d' |" % (team,minute) def wikiFG(num=10,prefix=False): goals=list() for ms in unmarshalMatches('parsed/match%02d.pkl'): if ms.hasResults: goals += ms.goals() print '\n\n==== Fastest goal ====\n'.encode('utf-8') print wikiFGheader(prefix).encode('utf-8') for (minute,team) in sorted(goals, key=itemgetter(0))[:num]: print wikiFGrow(team,minute,prefix).encode('utf-8') optfunc.main(wikiFG)
#!/usr/bin/python from globals import MatchStat, unmarshalMatches from optfunc import optfunc def wikiCALheader(): return '^ No. ^ When ^ %-88s ^ Score ^ Weighted Cards ^ First Goal ^' % ('Match') def wikiCALrow(ms): if ms.hasResults: results = '%d:%d' % (len(ms.homeGoals),len(ms.awayGoals)) try: firstgoal="**%d'** -- %s" % min(ms.goals()) except: firstgoal='//(no goals)//' ycrc = '**%d** (%d:%d)' % (ms.homeCards[3]+ms.awayCards[3], ms.homeCards[3], ms.awayCards[3]) else: results='' ycrc='' firstgoal='' return '| %5d | %16s | %-90s | %7s | %-14s | %-24s |' % (ms.number, ms.when, ms.matchTitle(), results, ycrc, firstgoal) def wikiCAL(title='Calendar', start=1, end=64): matches = unmarshalMatches('parsed/match%02d.pkl', end, start) print ( '\n\n===== %s =====\n' % (title) ).encode('utf-8') print wikiCALheader().encode('utf-8') for ms in matches: #already sorted by match number print wikiCALrow(ms).encode('utf-8') optfunc.main(wikiCAL)
from operator import itemgetter from optfunc import optfunc def wikiMGSheader(prefix): if prefix: return '^ # ^ %-50s ^ Goals scored ^ Goals against ^' % ('Team') else: return '^ %-50s ^ Goals scored ^ Goals against ^' % ('Team') def wikiMGSrow(team, goals, prefix): gf='**%d**' % (goals[0]) if prefix: return '| %3d | %-50s | %14s | %15d |' % (counter.next(),team,gf,-goals[1]) else: return '| %-50s | %14s | %15d |' % (team,gf,-goals[1]) def wikiMGS(num=10,prefix=False): mgs=dict() for ms in unmarshalMatches('parsed/match%02d.pkl'): if ms.hasResults: for team in [ms.homeWiki(), ms.awayWiki()]: if team not in mgs: mgs[team] = [0,0] mgs[ms.homeWiki()][0] += len(ms.homeGoals) mgs[ms.awayWiki()][0] += len(ms.awayGoals) mgs[ms.awayWiki()][1] -= len(ms.homeGoals) mgs[ms.homeWiki()][1] -= len(ms.awayGoals) print '\n\n==== Most goals scored ====\n'.encode('utf-8') print wikiMGSheader(prefix).encode('utf-8') for (team,goals) in list(reversed(sorted(mgs.items(), key=itemgetter(1))))[:num]: print wikiMGSrow(team,goals,prefix).encode('utf-8') optfunc.main(wikiMGS)
return "^ # ^ No. ^ When ^ %-88s ^ Goals scored ^" % ("Match") else: return "^ No. ^ When ^ %-88s ^ Goals scored ^" % ("Match") def wikiMGPGrow(ms, prefix): _goals = "**%d** (%d:%d)" % (ms.totalGoals, len(ms.homeGoals), len(ms.awayGoals)) if prefix: return "| %3d | %5d | %16s | %-90s | %-14s |" % (counter.next(), ms.number, ms.when, ms.matchTitle(), _goals) else: return "| %5d | %16s | %-90s | %-14s |" % (ms.number, ms.when, ms.matchTitle(), _goals) def wikiMGPG(num=10, prefix=False): matches = list() for ms in unmarshalMatches("parsed/match%02d.pkl"): if ms.hasResults: ms.totalGoals = len(ms.homeGoals) + len(ms.awayGoals) matches.append(ms) print "\n\n==== Most goals per game ====\n".encode("utf-8") print wikiMGPGheader(prefix).encode("utf-8") for ms in list(sorted(sorted(matches, key=lambda x: x.when_tm()), key=attrgetter("totalGoals"), reverse=True))[ :num ]: print wikiMGPGrow(ms, prefix).encode("utf-8") optfunc.main(wikiMGPG)
from globals import MatchStat, unmarshalMatches, counter from operator import attrgetter from optfunc import optfunc def wikiMYCPGheader(prefix): if prefix: return '^ # ^ No. ^ When ^ %-88s ^ Yellow ^ 2Y=R ^ Direct red ^ Weighted Total ^' % ('Match') else: return '^ No. ^ When ^ %-88s ^ Yellow ^ 2Y=R ^ Direct red ^ Weighted Total ^' % ('Match') def wikiMYCPGrow(ms,prefix): _yellow = '%d (%d:%d)' % (ms.homeCards[0]+ms.awayCards[0], ms.homeCards[0], ms.awayCards[0]) _yyr = '%d (%d:%d)' % (ms.homeCards[1]+ms.awayCards[1], ms.homeCards[1], ms.awayCards[1]) _red = '%d (%d:%d)' % (ms.homeCards[2]+ms.awayCards[2], ms.homeCards[2], ms.awayCards[2]) _total = '**%d** (%d:%d)' % (ms.homeCards[3]+ms.awayCards[3], ms.homeCards[3], ms.awayCards[3]) if prefix: return '| %3d | %5d | %16s | %-90s | %-12s | %-12s | %-12s | %-16s |' % (counter.next(),ms.number, ms.when, ms.matchTitle(), _yellow, _yyr, _red, _total) else:return '| %5d | %16s | %-90s | %-12s | %-12s | %-12s | %-16s |' % (ms.number, ms.when, ms.matchTitle(), _yellow, _yyr, _red, _total) def wikiMYCPG(num=10,prefix=False): matches=list() for ms in unmarshalMatches('parsed/match%02d.pkl'): if ms.hasResults: ms.totalCards = ms.homeCards[3]+ms.awayCards[3] matches.append(ms) print '\n\n==== Most yellow cards per game ====\n'.encode('utf-8') print wikiMYCPGheader(prefix).encode('utf-8') for ms in list(sorted( sorted(matches,key=lambda x:x.when_tm()) ,key=attrgetter('totalCards'), reverse=True))[:num]: print wikiMYCPGrow(ms,prefix).encode('utf-8') optfunc.main(wikiMYCPG)