| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import itertools |
||
| 2 | import sys |
||
| 3 | |||
| 4 | if sys.version_info >= (3, 9): |
||
| 5 | List = list |
||
| 6 | else: |
||
| 7 | from typing import List |
||
| 8 | |||
| 9 | from pathlib import Path |
||
| 10 | from typing import Optional |
||
| 11 | |||
| 12 | |||
| 13 | def normalize_eols(contents: str) -> str: |
||
| 14 | lines = contents.splitlines() |
||
| 15 | |||
| 16 | # Ensure last line has its EOL |
||
| 17 | if lines and lines[-1]: |
||
| 18 | lines.append("") |
||
| 19 | |||
| 20 | return "\n".join(lines) |
||
| 21 | |||
| 22 | |||
| 23 | def flatten_comma_separated_values(values: Optional[List[str]]) -> List[str]: |
||
| 24 | if not values: |
||
| 25 | return [] |
||
| 26 | |||
| 27 | return list(itertools.chain(*[ |
||
| 28 | filter( |
||
| 29 | len, |
||
| 30 | map( |
||
| 31 | str.strip, |
||
| 32 | x.split(","), |
||
| 33 | ), |
||
| 34 | ) |
||
| 35 | for x in values |
||
| 36 | ])) |
||
| 37 | |||
| 38 | |||
| 39 | def stringify_path(path: Path) -> str: |
||
| 40 | return str(path.as_posix()) |
||
| 41 |