Checks if a file is a text file
(filename)
| 551 | |
| 552 | |
| 553 | def _is_text_file(filename): |
| 554 | """ |
| 555 | Checks if a file is a text file |
| 556 | """ |
| 557 | type_of_file = subprocess.run( |
| 558 | ["file", "-bi", filename], |
| 559 | check=False, |
| 560 | stdout=subprocess.PIPE, |
| 561 | text=True, |
| 562 | ).stdout |
| 563 | return type_of_file.startswith("text") |
| 564 | |
| 565 | |
| 566 | def run(function, *args, **kwargs): |