DeaD_EyE

overengineered_Mac_Donald

May 2nd, 2020
721
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. 1.
  3. Old Mac Donald had a farm, I-A-I-A-O.
  4. And on his farm he had some chicks, I-A-I-A-O.
  5. With a chick-chick here, and a chick-chick there,
  6. here a chick, there a chick ev'rywhere a chick-chick.
  7.  
  8. 2.
  9. Old Mac Donald had a farm, I-A-I-A-O.
  10. And on his farm he had some ducks, I-A-I-A-O.
  11. With a quack-quack here, and a quack-quack there,
  12. here a quack, there a quack ev'rywhere a quack-quack.
  13. """
  14.  
  15. from rich import print
  16. # linux:
  17. # pip3 install rich
  18. # windows:
  19. # py -3 -m pip install rich
  20.  
  21.  
  22. def print_song(mapping):
  23.     print(mapping["begin"])
  24.     print()
  25.     animals = mapping["animals"].items()
  26.     for animal, sound in animals:
  27.         for line in mapping["text"]:
  28.             print(line.format(animal=animal, sound=sound))
  29.         print()
  30.     end = mapping["end"]
  31.     if end:
  32.         print(end)
  33.  
  34.  
  35. mapping = {
  36.     "begin": "[red]Old Mac Donald had a farm, [green]I-A-I-A-O.",
  37.     "end": "",
  38.     "animals": {"duck": "quack", "chicken": "chick", "dog": "woof",},
  39.     "text": [
  40.         "And on his farm he had some [red blink]{animal}s[/], [green]I-A-I-A-O.",
  41.         "With a [yellow blink]{sound}-{sound}[/] here, and a [yellow blink]{sound}-{sound}[/] there,",
  42.         "here a [yellow blink]{sound}[/], there a [yellow]{sound}[/] ev'rywhere a [yellow blink]{sound}-{sound}.",
  43.     ],
  44. }
  45.  
  46.  
  47. if __name__ == "__main__":
  48.     print_song(mapping)
RAW Paste Data