MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / fs_find_in_paths

Function fs_find_in_paths

pipcl.py:2959–2985  ·  view source on GitHub ↗

Looks for `name` in paths and returns complete path. `paths` is list/tuple or `os.pathsep`-separated string; if `None` we use `$PATH`. If `name` contains `/`, we return `name` itself if it is a file or None, regardless of .

( name, paths=None, verbose=False)

Source from the content-addressed store, hash-verified

2957
2958
2959def fs_find_in_paths( name, paths=None, verbose=False):
2960 '''
2961 Looks for `name` in paths and returns complete path. `paths` is list/tuple
2962 or `os.pathsep`-separated string; if `None` we use `$PATH`. If `name`
2963 contains `/`, we return `name` itself if it is a file or None, regardless
2964 of <paths>.
2965 ''&#x27;
2966 if '/' in name:
2967 return name if os.path.isfile( name) else None
2968 if paths is None:
2969 paths = os.environ.get( 'PATH', '')
2970 if verbose:
2971 log('From os.environ["PATH"]: {paths=}')
2972 if isinstance( paths, str):
2973 paths = paths.split( os.pathsep)
2974 if verbose:
2975 log('After split: {paths=}')
2976 for path in paths:
2977 p = os.path.join( path, name)
2978 if verbose:
2979 log('Checking {p=}')
2980 if os.path.isfile( p):
2981 if verbose:
2982 log('Returning because is file: {p!r}')
2983 return p
2984 if verbose:
2985 log('Returning None because not found: {name!r}')
2986
2987
2988def _get_prerequisites(path):

Callers 1

run_ifFunction · 0.85

Calls 2

logFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…