Spaces:
Running
Running
File size: 1,888 Bytes
f8c2dc7 81193ca f8c2dc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | from enum import Enum
from typing import Optional
class EnumWithFrValue(Enum):
def __new__(cls, value, fr_value):
member = object.__new__(cls)
member._value_ = value
member._fr_value = fr_value
return member
@property
def fr_value(self):
return self._fr_value
@classmethod
def get_by_value(cls, value: Optional[str]) -> Optional[Enum]:
if value:
for member in cls:
if member.value == value:
return member
return None
@classmethod
def get_fr_value_from_value(cls, value: Optional[str]) -> str:
if value:
for member in cls:
if member.value == value:
return member.fr_value
return value
else:
return ""
class Round(EnumWithFrValue):
FIRST = ("1st Round", "1er Tour")
SECOND = ("2nd Round", "2e Tour")
THIRD = ("3rd Round", "3e Tour")
FOURTH = ("4th Round", "4e Tour")
QUARTER = ("Quarterfinals", "Quarts de Finale")
SEMI = ("Semifinals", "Demi-Finales")
FINAL = ("The Final", "La Finale")
ROUND_ROBIN = ("Round Robin", "Phase de Poules")
class Surfaces(EnumWithFrValue):
HARD = ("Hard", "Dur")
CLAY = ("Clay", "Terre Battue")
GRASS = ("Grass", "Gazon")
CARPET = ("Carpet", "Synthétique")
class Courts(EnumWithFrValue):
INDOOR = ("Indoor", "Intérieur")
OUTDOOR = ("Outdoor", "Extérieur")
class Series(EnumWithFrValue):
ATP250 = ("ATP250", "ATP 250")
ATP500 = ("ATP500", "ATP 500")
MASTERS = ("Masters", "Masters")
MASTERS_1000 = ("Masters 1000", "Masters 1000")
MASTERS_CUP = ("Masters Cup", "Masters Cup")
GRAND_SLAM = ("Grand Slam", "Grand Chelem")
INTERNATIONAL = ("International", "International")
INTERNATIONAL_GOLD = ("International Gold", "International Gold")
|