Détermination du bord politique de mots divers http://clivage.foxgl.ovh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
985 B

  1. from random import randint
  2. class WordResult:
  3. def __init__(self, word, left, right, url):
  4. self.word = word
  5. self.left = left
  6. self.right = right
  7. self.left_percentage = round(left / (left + right) * 100, 1)
  8. self.right_percentage = 100 - self.left_percentage
  9. if left > right:
  10. self.major = -1
  11. elif right > left:
  12. self.major = 1
  13. else:
  14. self.major = 0
  15. self.url = url
  16. class UIColor:
  17. colorlist = ("F44336", "E91E63", "9C27B0", "673AB7", "3F51B5", "2196F3", "03A9F4", "00BCD4", "009688", "4CAF50",
  18. "8BC34A", "CDDC39", "FFEB3B", "FFC107", "FF9800", "FF5722", "795548", "607D8B")
  19. @classmethod
  20. def color_from(cls, input_string: str):
  21. return "#" + cls.colorlist[
  22. sum(input_string.encode('utf-8')) % len(cls.colorlist)]
  23. @classmethod
  24. def color_random(cls):
  25. return "#" + cls.colorlist[randint(0, len(cls.colorlist) - 1)]