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.
 
 
 
 

50 lines
1.5 KiB

  1. #!/usr/bin/env python3
  2. import aurornis
  3. import re
  4. from os import environ
  5. from typing import Union
  6. DEFAULT_ENVIRONMENT = {"PATH": environ["PATH"]}
  7. KOSMORRO = ["kosmorro", "--no-color"]
  8. CURRENT_MOON_PHASE_PATTERN = re.compile(
  9. r"^Moon phase: ("
  10. r"(New Moon)|(Waxing Crescent)|"
  11. r"(First Quarter)|(Waxing Gibbous)|"
  12. r"(Full Moon)|(Waning Gibbous)|"
  13. r"(Last Quarter)|(Waning Crescent)"
  14. r")$"
  15. )
  16. NEXT_MOON_PHASE_PATTERN = re.compile(
  17. r"^((New Moon)|(Waxing Crescent)|"
  18. r"(First Quarter)|(Waxing Gibbous)|"
  19. r"(Full Moon)|(Waning Gibbous)|"
  20. r"(Last Quarter)|(Waning Crescent)) "
  21. r"on ((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday)), "
  22. r"((January)|(February)|(March)|(April)|(May)|(June)|"
  23. r"(July)|(August)|(September)|(October)|(November)|(December)) "
  24. r"[0-9]{1,2}, [0-9]{4} at [0-9]{1,2}:[0-9]{2} [AP]M$"
  25. )
  26. def execute(
  27. command, environment: {str: Union[int, str]} = None
  28. ) -> aurornis.CommandResult:
  29. if environment is None:
  30. environment = DEFAULT_ENVIRONMENT
  31. else:
  32. for variable in DEFAULT_ENVIRONMENT:
  33. environment[variable] = DEFAULT_ENVIRONMENT[variable]
  34. return aurornis.run(command, environment)
  35. def assert_nb_lines(expected_nb: int, in_str: str):
  36. """Check that the string has the specified number of lines and that the last one is empty."""
  37. lines = in_str.split("\n")
  38. assert len(lines) == expected_nb
  39. assert lines[len(lines) - 1] == ""