Works exactly like the unix command which Courtesy of http://stackoverflow.com/a/377028/675646
(filename)
| 738 | |
| 739 | |
| 740 | def which(filename): |
| 741 | """ |
| 742 | Works exactly like the unix command which |
| 743 | Courtesy of http://stackoverflow.com/a/377028/675646 |
| 744 | """ |
| 745 | dirname, basename = os.path.split(filename) |
| 746 | |
| 747 | if dirname: |
| 748 | return filename if isexecutable(filename) else None |
| 749 | |
| 750 | else: |
| 751 | for path in os.environ['PATH'].split(os.pathsep): |
| 752 | filename = os.path.join(path.strip('"'), filename) |
| 753 | if isexecutable(filename): |
| 754 | return filename |
| 755 | |
| 756 | |
| 757 | def format_exc(frame=None): |
no test coverage detected