Tool to tally up langjam votes.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import os
  2. jamdir = "jam0001"
  3. votesfile = "rawvotes.txt"
  4. teams = {}
  5. users = {}
  6. for realTeamName in os.listdir(jamdir):
  7. if not os.path.exists(f"{jamdir}/{realTeamName}/TEAM"): continue
  8. teamName = realTeamName.lower()
  9. team = {"name": teamName, "users": [], "tally": 0}
  10. teams[teamName] = team
  11. with open(f"{jamdir}/{realTeamName}/TEAM") as f:
  12. for line in f:
  13. for name in line.split():
  14. name = name.strip().lower()
  15. if name[0] == "@": name = name[1:]
  16. if name.startswith("[delete this line"): continue
  17. if name == "": continue
  18. users[name] = teamName
  19. team["users"].append(name)
  20. with open(votesfile) as f:
  21. for line in f:
  22. issueName, count, voters = line[:-1].split(";")
  23. if not issueName.startswith("Team: "): continue
  24. voters = voters.strip()
  25. if voters == "": continue
  26. teamName = issueName.replace("Team: ", "")
  27. teamName = teamName.lower()
  28. voters = map(lambda x: x.strip().lower(), voters.split(":"))
  29. team = teams[teamName]
  30. for voter in voters:
  31. if voter not in users:
  32. print("Vote from non-participant:", voter, "voted for", team["name"])
  33. elif users[voter] == teamName:
  34. print("Self-vote:", voter, "voted for their own team", team["name"])
  35. else:
  36. team['tally'] += 1
  37. for team in sorted(teams.values(), key=lambda team: team["tally"]):
  38. print(f"{team['name']}: {team['tally']}")