Opens the file handle of file `fname`.
(fname)
| 614 | |
| 615 | |
| 616 | def openfile(fname): |
| 617 | """ |
| 618 | Opens the file handle of file `fname`. |
| 619 | |
| 620 | """ |
| 621 | # A file handle |
| 622 | if hasattr(fname, 'readline'): |
| 623 | return fname |
| 624 | # Try to open the file and guess its type |
| 625 | try: |
| 626 | f = open(fname) |
| 627 | except FileNotFoundError as e: |
| 628 | raise FileNotFoundError(f"No such file: '{fname}'") from e |
| 629 | if f.readline()[:2] != "\\x": |
| 630 | f.seek(0, 0) |
| 631 | return f |
| 632 | f.close() |
| 633 | raise NotImplementedError("Wow, binary file") |
| 634 | |
| 635 | |
| 636 | def fromtextfile(fname, delimiter=None, commentchar='#', missingchar='', |
no test coverage detected
searching dependent graphs…