Team.py 709 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python2
  2. class Team:
  3. teamId = ""
  4. points = 0
  5. region = ""
  6. def __init__(self, _input):
  7. if len(_input) < 2 or len(_input) > 3:
  8. raise ValueError()
  9. self.teamId = "/".join(sorted(_input[0].split("/"), key=lambda a: int(a))) if "/" in _input[0] else _input[0]
  10. self.region = _input[1].upper()
  11. if len(_input) == 3:
  12. self.points = int(_input[2])
  13. def __eq__(self, other):
  14. return type(self) == type(other) and self.teamId == other.teamId and self.region == other.region
  15. def __ne__(self, other):
  16. return not __eq(self, other)
  17. def __hash__(self):
  18. return hash(self.teamId + "\x0E\x0F" + self.region)