utils.py 489 B

12345678910111213141516171819202122
  1. """Pylama utils."""
  2. from io import StringIO
  3. from sys import stdin
  4. from typing import List
  5. def get_lines(value: str) -> List[str]:
  6. """Return lines from the given string."""
  7. return StringIO(value).readlines()
  8. def read(filename: str) -> str:
  9. """Read the given filename."""
  10. with open(filename, encoding="utf-8") as file:
  11. return file.read()
  12. def read_stdin() -> str:
  13. """Get value from stdin."""
  14. value = stdin.buffer.read()
  15. return value.decode("utf-8")