Opens the file handle of file `fname`.
(fname)
| 647 | |
| 648 | |
| 649 | def openfile(fname): |
| 650 | """ |
| 651 | Opens the file handle of file `fname`. |
| 652 | |
| 653 | """ |
| 654 | # A file handle |
| 655 | if hasattr(fname, 'readline'): |
| 656 | return fname |
| 657 | # Try to open the file and guess its type |
| 658 | try: |
| 659 | f = open(fname) |
| 660 | except FileNotFoundError as e: |
| 661 | raise FileNotFoundError(f"No such file: '{fname}'") from e |
| 662 | if f.readline()[:2] != "\\x": |
| 663 | f.seek(0, 0) |
| 664 | return f |
| 665 | f.close() |
| 666 | raise NotImplementedError("Wow, binary file") |
| 667 | |
| 668 | |
| 669 | def fromtextfile(fname, delimiter=None, commentchar='#', missingchar='', |
no test coverage detected