(ignore_file: str)
| 46 | |
| 47 | |
| 48 | def excludes_from_file(ignore_file: str) -> list[str]: |
| 49 | excludes: list[str] = [] |
| 50 | try: |
| 51 | with io.open(ignore_file, "r", encoding="utf-8") as f: |
| 52 | for line in f: |
| 53 | if line.startswith("#"): |
| 54 | # ignore comments |
| 55 | continue |
| 56 | pattern = line.rstrip() |
| 57 | if not pattern: |
| 58 | # allow empty lines |
| 59 | continue |
| 60 | excludes.append(pattern) |
| 61 | except EnvironmentError as e: |
| 62 | if e.errno != errno.ENOENT: |
| 63 | raise |
| 64 | return excludes |
| 65 | |
| 66 | |
| 67 | def list_files( |