Recursively read all .py files in the specified directory and return their contents.
(directory)
| 409 | return all_files_content |
| 410 | |
| 411 | def 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 | |
| 425 | def extract_json_from_string(text): |
no outgoing calls
no test coverage detected