コード例 #1
0
ファイル: parseMatchPage.py プロジェクト: netvor/fhwcs
#!/usr/bin/python

from globals import MatchStat, getInFile, marshal, unmarshal
from lxml import etree
from whohas import whohas
import sys, re

tree = etree.parse(getInFile(''),etree.HTMLParser())

div = tree.xpath('//div[@id="fwcMatchHeader"]')[0]
ms = MatchStat()
ms.number = int(div.xpath('./div[@class="footer"]/div[@class="info"]/span[@class="matchInfo L"]')[0].text[6:])

try:
  oldms = unmarshal('parsed/match%02d.pkl'%(ms.number),None)
  if isinstance(oldms,MatchStat):
    print "Skipping, parsed/match%02d.pkl exists"%(ms.number)
    sys.exit(0) # MatchStat exists, abort parsing.
except IOError:
  pass # file not found means go on, the MatchStat does not yet exist! 

assert(ms.number == int(div.xpath('./div[@class="footer"]/div[@class="info"]/span')[0].text[6:]))

ms.group = div.xpath('./div[@class="footer"]/div[@class="info"]/span')[1].text
ms.group = re.search('\w[\w -]+\w', ms.group).group()
if 'GROUP ' in ms.group.upper():
  ms.group = ms.group[6:].upper()


whdate = div.xpath('./div[@class="footer"]/div[@class="info"]/span')[2].text
whtime = div.xpath('./div[@class="match"]/div[@class="time"]')[0].text
コード例 #2
0
ファイル: wikiLSIGS.py プロジェクト: netvor/fhwcs
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")
コード例 #3
0
ファイル: parseMatchReport.py プロジェクト: netvor/fhwcs
report = { 'homeCode'  : teams['h']    , 
           'homeName'  : teams['hhhh'] ,
           'awayCode'  : teams['a']    ,
           'awayName'  : teams['aaaa'] ,
           'number'    : number        ,
           'goals'     : goals         ,
           'homeGoals' : homeGoals     ,
           'awayGoals' : awayGoals     ,
           'homeCards' : homeCards     ,
           'awayCards' : awayCards     }


### Part two: integrating the match report data with an existing MatchStat instance


ms=unmarshal('parsed/match%02d.pkl'%(report['number']),None)

assert(ms.homeCode == report['homeCode'])
assert(ms.awayCode == report['awayCode'])
assert(ms.homeName == report['homeName'])
assert(ms.awayName == report['awayName'])

ms.goalsCode  = report['goals']
ms.homeGoals  = report['homeGoals']
ms.awayGoals  = report['awayGoals']
ms.homeCards  = report['homeCards']
ms.awayCards  = report['awayCards']
ms.hasResults = True

res = '%d:%d' % (len(ms.homeGoals),len(ms.awayGoals))
try: fg="%d' -- %s" % min(ms.goalsCode)
コード例 #4
0
ファイル: wikiGSS.py プロジェクト: netvor/fhwcs
#!/usr/bin/python

from globals import TeamStat, teamSorted, unmarshal
import string
from collections import deque

standings = unmarshal('parsed/gss.pkl')

def wikiGSSheader(letter):
  return '^ //Group %s://%38s ^  %-2s  ^  %-8s  ^  %-5s  ^  %-2s  ^  %-3s  ^' % (letter.upper(),' ','MP','W/D/L','GF/GA','GD','Pts')

def wikiGSSrow(ts):
  wdl = '%d/%d/%d' % (ts.wins,ts.draws,ts.losses)
  gfga = '%d/%d' % (ts.goalsFor, ts.goalsAgainst)
  return '| %-50s | %4d |  %-8s  |  %-5s  | %4d | %5d |' % (ts.teamWiki(), ts.played, wdl, gfga, ts.goalsDiff, ts.points)

wikiGSSdata=deque()

for letter in string.ascii_uppercase[:8]:
  group=[ wikiGSSheader(letter) ]
  for row in teamSorted(filter(lambda ts: ts.group==letter,standings)):
    group.append(wikiGSSrow(row))
  wikiGSSdata.append(group)

print '\n\n===== Final Standings =====\n\n'.encode('utf-8')

while len(wikiGSSdata) >= 2:
  a=wikiGSSdata.popleft()
  b=wikiGSSdata.popleft()
  print (a[0] + '     ' + b[0]).encode('utf-8')
  print (a[1] + ' ::: ' + b[1]).encode('utf-8')
コード例 #5
0
ファイル: promptMatchStats.py プロジェクト: netvor/fhwcs
#!/usr/bin/python

from globals import MatchStat, getInFile, marshal, unmarshal
import re

ms = unmarshal("")

print "Editing match %d: %s vs. %s (%s)" % (ms.number, ms.homeName, ms.awayName, ms.when)

_homeGoals = raw_input(
    "Goals scored by %s (write the minute of each goal, separated by spaces): " % ms.homeName
).split()
_awayGoals = raw_input(
    "Goals scored by %s (write the minute of each goal, separated by spaces): " % ms.awayName
).split()
_homeCards = raw_input(
    "Yellow, 2Y=R and red cards given to %s (separate three values by spaces): " % ms.homeName
).split()
_awayCards = raw_input(
    "Yellow, 2Y=R and red cards given to %s (separate three values by spaces): " % ms.awayName
).split()

homeGoals = list()
awayGoals = list()
homeCards = [0, 0, 0]
awayCards = [0, 0, 0]

for g in _homeGoals:
    m = int(g)
    homeGoals.append(m)
for g in _awayGoals: