Untitled

From Idiotic Gorilla, 6 Days ago, written in Plain Text, viewed 4 times. This paste will bite the big one in 3 Weeks.
URL https://paste.afonso.co/view/b84460a9 Embed
Download Paste or View Raw
  1. def fillScorers(stat, team, viewBag):
  2.         idx = 1
  3.         count = 0
  4.         lines = 0
  5.         tagsDict = {}
  6.         font = Font("Arial", 12)
  7.        
  8.         for item in stat:
  9.                 player = item[-1]
  10.                
  11.                 name = player.ShortName
  12.        
  13.                 goalTimes = []
  14.                 previousGoalTimes = []
  15.                 translate = False
  16.                
  17.                 for i, goal in enumerate(item[1]):
  18.                         isPen = item[7][i]
  19.                         isOG = item[6][i]
  20.                         appendValue = ""       
  21.                         if goal.Contains("+") and goal[-1] == "'":     
  22.                                 goal = goal.rstrip(goal[-1])
  23.                                
  24.                         if isPen:
  25.                                 translate = True
  26.                                 appendValue = ("%s {{(P)}}" % goal)
  27.                         elif isOG:
  28.                                 translate = True
  29.                                 appendValue = ("%s {{(OG)}}" % goal)
  30.                         else:
  31.                                 appendValue = (goal)
  32.                                
  33.                         goalTimes.append(appendValue)
  34.                        
  35.                         tempTimes = " ".join(goalTimes)
  36.                         tempTotalStr = name + " " + tempTimes
  37.                         if idx in tagsDict:
  38.                                 tempTotalStr = tagsDict[idx][1].TrimEnd() + ", " + tempTotalStr
  39.  
  40.                         width = measure_text_width(tempTotalStr.replace("{","").replace("}",""), font)
  41.  
  42.                         if width > lineLen:
  43.                                 if previousGoalTimes:
  44.                                         times = " ".join(previousGoalTimes)
  45.                                         if idx in tagsDict:
  46.                                                 tagsDict[idx] = (translate or tagsDict[idx][0], "%s, %s %s " % (tagsDict[idx][1].TrimEnd(), name, times))
  47.                                         else:
  48.                                                 tagsDict[idx] = (translate, "%s %s " % (name, times))
  49.                                         goalTimes = []
  50.                                         previousGoalTimes = []
  51.                                         goalTimes.append(appendValue)
  52.                                         idx += 1
  53.                                 elif idx in tagsDict:
  54.                                         idx += 1
  55.                         previousGoalTimes = goalTimes[:]
  56.                        
  57.                        
  58.                 times = " ".join(goalTimes)
  59.                 totalStr = name + " " + times.replace("{","").replace("}","")
  60.                 width2 = measure_text_width(totalStr, font)
  61.                
  62.                 count += width2
  63.  
  64.                 if count > lineLen:
  65.                         idx += 1
  66.                         count = width2
  67.                        
  68.                 if idx in tagsDict:
  69.                         tagsDict[idx] = (translate or tagsDict[idx][0], "%s %s %s " % (tagsDict[idx][1].TrimEnd() + ", ", name, times))
  70.                 else:
  71.                         tagsDict[idx] = (translate, "%s %s " % (name, times))
  72.                
  73.         total = len(tagsDict)
  74.        
  75.         if team == "Home":
  76.                 i = 1
  77.                 for ignore, value in tagsDict.items():
  78.                         lines += 1
  79.                         translate, name = value
  80.                         if translate:
  81.                                
  82.                                 viewBag.SetTranslatedText("tHomeTeamScorer%02d" % i, name)
  83.                         else:
  84.                                 viewBag.SetString("tHomeTeamScorer%02d" % i, name)
  85.                         i += 1
  86.         if team == "Away":
  87.                 i = 1
  88.                 for ignore, value in tagsDict.items():
  89.                         lines += 1
  90.                         translate, name = value
  91.                         if translate:
  92.                        
  93.                                 viewBag.SetTranslatedText("tAwayTeamScorer%02d" % i, name)
  94.                         else:
  95.                                 viewBag.SetString("tAwayTeamScorer%02d" % i, name)
  96.                         i+= 1
  97.        
  98.         return lines

Reply to "Untitled"

Here you can reply to the paste above