| Total Complexity | 2 |
| Total Lines | 14 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import codecs |
||
| 2 | |||
| 3 | from pathlib import Path |
||
| 4 | |||
| 5 | |||
| 6 | def has_bom(file_path: Path) -> bool: |
||
| 7 | with file_path.open("rb") as f: |
||
| 8 | sample = f.read(4) |
||
| 9 | |||
| 10 | return ( |
||
| 11 | sample[:3] == b"\xef\xbb\xbf" |
||
| 12 | or sample.startswith(codecs.BOM_UTF16_LE) |
||
| 13 | or sample.startswith(codecs.BOM_UTF16_BE) |
||
| 14 | ) |
||
| 15 |