選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

51 行
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") "
  22. r"on ((Monday)|(Tuesday)|(Wednesday)|(Thursday)|(Friday)|(Saturday)|(Sunday)), "
  23. r"((January)|(February)|(March)|(April)|(May)|(June)|"
  24. r"(July)|(August)|(September)|(October)|(November)|(December)) "
  25. r"[0-9]{1,2}, [0-9]{4} at [0-9]{2}:[0-9]{2} [AP]M$"
  26. )
  27. def execute(
  28. command, environment: {str: Union[int, str]} = None
  29. ) -> aurornis.CommandResult:
  30. if environment is None:
  31. environment = DEFAULT_ENVIRONMENT
  32. else:
  33. for variable in DEFAULT_ENVIRONMENT:
  34. environment[variable] = DEFAULT_ENVIRONMENT[variable]
  35. return aurornis.run(command, environment)
  36. def assert_nb_lines(expected_nb: int, in_str: str):
  37. """Check that the string has the specified number of lines and that the last one is empty."""
  38. lines = in_str.split("\n")
  39. assert len(lines) == expected_nb
  40. assert lines[len(lines) - 1] == ""