MCPcopy Index your code
hub / github.com/going-doer/Paper2Code / read_python_files

Function read_python_files

codes/utils.py:411–422  ·  view source on GitHub ↗

Recursively read all .py files in the specified directory and return their contents.

(directory)

Source from the content-addressed store, hash-verified

409 return all_files_content
410
411def read_python_files(directory):
412 """Recursively read all .py files in the specified directory and return their contents."""
413 python_files_content = {}
414
415 for root, _, files in os.walk(directory): # Recursively traverse directories
416 for filename in files:
417 if filename.endswith(".py"): # Check if file has .py extension
418 relative_path = os.path.relpath(os.path.join(root, filename), directory) # Preserve directory structure
419 with open(os.path.join(root, filename), "r", encoding="utf-8") as file:
420 python_files_content[relative_path] = file.read()
421
422 return python_files_content
423
424
425def extract_json_from_string(text):

Callers 3

mainFunction · 0.90
3.1_coding_sh.pyFile · 0.90
4_debugging.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected