MCPcopy Index your code
hub / github.com/python/cpython / findfile

Function findfile

Lib/test/support/__init__.py:791–807  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

789
790
791def 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
810def sortdict(dict):

Callers 15

test_sax.pyFile · 0.90
test_html_diffMethod · 0.90
test_command_usageMethod · 0.90
test_pulldom.pyFile · 0.90
test_xml_etree.pyFile · 0.90
test_xml_c14n2Method · 0.90
setUpClassMethod · 0.90
abspathFunction · 0.90
test_extract_dirMethod · 0.90

Calls 3

isabsMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by 15

test_html_diffMethod · 0.72
test_command_usageMethod · 0.72
test_xml_c14n2Method · 0.72
setUpClassMethod · 0.72
abspathFunction · 0.72
test_extract_dirMethod · 0.72
test_test_commandMethod · 0.72
test_list_commandMethod · 0.72
test_extract_commandMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…