MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / get_module_scripts

Function get_module_scripts

src/packagedcode/pypi.py:2886–2916  ·  view source on GitHub ↗

Yield interesting Python script paths that have a name in `interesting_names` by walking the `location` directory recursively up to `max_depth` path segments extending from the root `location`.

(location, max_depth=1, interesting_names=())

Source from the content-addressed store, hash-verified

2884
2885
2886def get_module_scripts(location, max_depth=1, interesting_names=()):
2887 """
2888 Yield interesting Python script paths that have a name in
2889 `interesting_names` by walking the `location` directory recursively up to
2890 `max_depth` path segments extending from the root `location`.
2891 """
2892 if TRACE:
2893 logger_debug(
2894 ' get_module_scripts():',
2895 'location:', location,
2896 'max_depth:', max_depth,
2897 'interesting_names:', interesting_names
2898 )
2899
2900 location = location.rstrip(os.path.sep)
2901 if TRACE: logger_debug(' get_module_scripts:', 'location:', location)
2902
2903 for top, _dirs, files in os.walk(location):
2904 current_depth = compute_path_depth(location, top)
2905 if TRACE:
2906 logger_debug(' get_module_scripts:', 'current_depth:', current_depth)
2907 logger_debug(' get_module_scripts:', 'top:', top, '_dirs:', _dirs, 'files:', files)
2908 if current_depth >= max_depth:
2909 break
2910 for f in files:
2911 if TRACE: logger_debug(' get_module_scripts:', 'file:', f)
2912
2913 if f in interesting_names:
2914 path = os.path.join(top, f)
2915 if TRACE: logger_debug(' get_module_scripts:', 'path:', path)
2916 yield path
2917
2918
2919def compute_path_depth(base, path):

Callers 1

detect_version_attributeFunction · 0.85

Calls 4

compute_path_depthFunction · 0.85
logger_debugFunction · 0.70
walkMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected