Untitled

From Sludgy Cheetah, 2 Weeks ago, written in Python, viewed 2 times. This paste will perish in 1 Week.
URL https://paste.afonso.co/view/2d484784 Embed
Download Paste or View Raw
  1. import StaticLib
  2. from Wtvision.Sports.Models.Football import FootballEventAttributes
  3.  
  4.  
  5. def __onStart(graphicOnAirItem, momentExecution, workFlowtype):
  6.         if workFlowtype.ToString() != "PreviewToProgram":
  7.                 if not Game.Clock.ActivePart.Number == 9:
  8.                         momentExecution.Message = "You're not on Penalties part!"
  9.                         momentExecution.Cancel = True
  10.                         return
  11.  
  12. def __getData(graphicOnAirItem, viewBag, momentExecution):
  13.         hometeam = Game.HomeTeam
  14.         awayteam = Game.AwayTeam
  15.         homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))    
  16.         awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))
  17.        
  18. #       currentPenalty= max(len(homePenaltysEvent),len(awayPenaltysEvent))
  19. #      
  20. #       viewBag.SetFloat("vPenaltyPosition", 1)
  21. #       homeGoals,awayGoals = __getGoals(homePenaltysEvent,awayPenaltysEvent)
  22. #       if currentPenalty > 5:
  23. #               if homeGoals == awayGoals:
  24. #                       viewBag.SetFloat("vPenaltyPosition", currentPenalty-3)
  25. #               else:
  26. #                       viewBag.SetFloat("vPenaltyPosition", currentPenalty-4)
  27. #       elif currentPenalty == 5:
  28. #               if homeGoals == awayGoals:
  29. #                       viewBag.SetFloat("vPenaltyPosition", 2)
  30. #      
  31. #      
  32.         print homePenaltysEvent
  33.         print awayPenaltysEvent
  34.         __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent)
  35.        
  36.        
  37. def __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent):
  38.         hometeam = Game.HomeTeam
  39.         awayteam = Game.AwayTeam
  40.  
  41.         viewBag.SetString("tHomeTeamScore", GameOnline.HomeTeamPenaltiesScore)
  42.         viewBag.SetString("tAwayTeamScore", GameOnline.AwayTeamPenaltiesScore)
  43.         total = len(homePenaltysEvent) + len(awayPenaltysEvent)
  44.         if total == 0:
  45.                 for i in range(1,6):
  46.                         viewBag.SetString("vHomePenaltie%02d" % i,1)
  47.                         viewBag.SetString("vAwayPenaltie%02d" % i,1)
  48. #       else:
  49. #               if Globals["PenaltiesForm"].IsHomeStarting:
  50. #                      
  51. #                       if (total % 2) == 0:
  52. #                               viewBag.SetString("vHomePenalty%02d" % (len(homePenaltysEvent)+1),2)
  53. #                       else:
  54. #                               viewBag.SetString("vAwayPenalty%02d" % (len(awayPenaltysEvent)+1),2)
  55. #               else:
  56. #                       if (total % 2) == 0:
  57. #                               viewBag.SetString("vAwayPenalty%02d" % (len(awayPenaltysEvent)+1),2)
  58. #                       else:
  59. #                               viewBag.SetString("vHomePenalty%02d" % (len(homePenaltysEvent)+1),2)
  60.                
  61.         homePenaltysEvent = list(homePenaltysEvent)[-30:]
  62.         awayPenaltysEvent = list(awayPenaltysEvent)[-30:]
  63.  
  64.         for i, homePenaltyEvent in enumerate(homePenaltysEvent):
  65.                
  66.                 penaltyKickResult = next((pAttribute for pAttribute in list(homePenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None)
  67.                 if not penaltyKickResult: continue
  68.                
  69.                 isGoal = (penaltyKickResult.Value == "Goal")
  70.  
  71.                 viewBag.SetFloat("vHomePenaltie01", 2)
  72.                
  73.                 if isGoal:
  74.                         viewBag.SetFloat("vHomePenaltie%02d" % (i+1), 2)
  75.                         viewBag.SetString("tHomeTeamScore", GameOnline.HomeTeamPenaltiesScore)
  76.                 else:
  77.                         viewBag.SetString("vHomePenaltie%02d" % (i+1), 3)
  78.                        
  79.         for i, awayPenaltyEvent in enumerate(awayPenaltysEvent):
  80.                 penaltyKickResult = next((pAttribute for pAttribute in list(awayPenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None)
  81.                 if not penaltyKickResult: continue
  82.                
  83.                 isGoal = (penaltyKickResult.Value == "Goal")
  84.                
  85.                 if isGoal:
  86.                         viewBag.SetString("vAwayPenaltie%02d" % (i+1), 2)
  87.                         viewBag.SetString("tAwayTeamScore", GameOnline.AwayTeamPenaltiesScore)
  88.                 else:
  89.                         viewBag.SetString("vAwayPenaltie%02d" % (i+1), 3)
  90.                
  91.                 onairItems = IntelliflowController.GetGraphicOnAirItems(OutputManager.ActiveChannelOutput)
  92.                 for item in onairItems:
  93.                         graphName = item.Graphic.Name
  94.                         if "PENALTIES" in graphName:
  95.                                 graphic = item
  96.                                 graphic.Scene.FillTags(viewBag)
  97.  
  98. def __updatePenalties():
  99.         graphic = GraphicTemplatesManager.GetGraphicByName("PENALTIES")
  100.         graphicOnAirItems = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput)
  101.         if not graphicOnAirItems:return
  102.         viewBag = IntelliflowController.CreateViewBag()
  103.         hometeam = Game.HomeTeam
  104.         awayteam = Game.AwayTeam
  105.         homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))    
  106.         awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))
  107.         __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent)
  108.         #IntelliflowController.FillData(graphicOnAirItems, viewBag, True)
  109.         maxPen = max(len(homePenaltysEvent),len(awayPenaltysEvent))
  110.         homeGoals,awayGoals = __getGoals(homePenaltysEvent,awayPenaltysEvent)
  111. #       if len(homePenaltysEvent) >= 5 and len(awayPenaltysEvent) >=5 and len(homePenaltysEvent) == len(awayPenaltysEvent)  and homeGoals == awayGoals:
  112. #               if maxPen >=30:return
  113. #               IntelliflowController.Continue(graphic, OutputManager.ActiveChannelOutput)
  114.  
  115. def __getGoals(homePenaltysEvent,awayPenaltysEvent):
  116.         homeGoals = 0
  117.         for i, homePenaltyEvent in enumerate(homePenaltysEvent):
  118.                 penaltyKickResult = next((pAttribute for pAttribute in list(homePenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None)
  119.                 if not penaltyKickResult: continue
  120.                 isGoal = (penaltyKickResult.Value == "Goal")
  121.                 if isGoal:
  122.                         homeGoals+=1
  123.         awayGoals = 0
  124.         for i, awayPenaltyEvent in enumerate(awayPenaltysEvent):
  125.                 penaltyKickResult = next((pAttribute for pAttribute in list(awayPenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None)
  126.                 if not penaltyKickResult: continue
  127.                 isGoal = (penaltyKickResult.Value == "Goal")
  128.                 if isGoal:
  129.                         awayGoals+=1
  130.        
  131.         return homeGoals,awayGoals
  132.        
  133. def __beforeProgram(graphicOnAirItem, momentExecution):
  134.         hometeam = Game.HomeTeam
  135.         awayteam = Game.AwayTeam
  136.         homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))    
  137.         awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents))
  138.         viewbag = graphicOnAirItem.Graphic.ViewData
  139.         __showPenalties(viewbag,homePenaltysEvent,awayPenaltysEvent)

Reply to "Untitled"

Here you can reply to the paste above