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)
| 701 | |
| 702 | |
| 703 | def findfile(filename, subdir=None): |
| 704 | """Try to find a file on sys.path or in the test directory. If it is not |
| 705 | found the argument passed to the function is returned (this does not |
| 706 | necessarily signal failure; could still be the legitimate path). |
| 707 | |
| 708 | Setting *subdir* indicates a relative path to use to find the file |
| 709 | rather than looking directly in the path directories. |
| 710 | """ |
| 711 | if os.path.isabs(filename): |
| 712 | return filename |
| 713 | if subdir is not None: |
| 714 | filename = os.path.join(subdir, filename) |
| 715 | path = [TEST_HOME_DIR] + sys.path |
| 716 | for dn in path: |
| 717 | fn = os.path.join(dn, filename) |
| 718 | if os.path.exists(fn): return fn |
| 719 | return filename |
| 720 | |
| 721 | |
| 722 | def sortdict(dict): |