Try to find a file on sys.path or in the test directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path). Setting *subdir* indicates a relative path to use to find the file rather than
(filename, subdir=None)
| 789 | |
| 790 | |
| 791 | def findfile(filename, subdir=None): |
| 792 | """Try to find a file on sys.path or in the test directory. If it is not |
| 793 | found the argument passed to the function is returned (this does not |
| 794 | necessarily signal failure; could still be the legitimate path). |
| 795 | |
| 796 | Setting *subdir* indicates a relative path to use to find the file |
| 797 | rather than looking directly in the path directories. |
| 798 | """ |
| 799 | if os.path.isabs(filename): |
| 800 | return filename |
| 801 | if subdir is not None: |
| 802 | filename = os.path.join(subdir, filename) |
| 803 | path = [TEST_HOME_DIR] + sys.path |
| 804 | for dn in path: |
| 805 | fn = os.path.join(dn, filename) |
| 806 | if os.path.exists(fn): return fn |
| 807 | return filename |
| 808 | |
| 809 | |
| 810 | def sortdict(dict): |
searching dependent graphs…