Find the prompts_raw directory and generate an __init__.py file containing prompt texts. Searches for prompts_raw directory in current and parent directories. Once found, calls create_python_file_with_texts() to generate the __init__.py file.
()
| 3 | |
| 4 | |
| 5 | def call_parse_prompt(): |
| 6 | """ |
| 7 | Find the prompts_raw directory and generate an __init__.py file containing prompt texts. |
| 8 | |
| 9 | Searches for prompts_raw directory in current and parent directories. Once found, |
| 10 | calls create_python_file_with_texts() to generate the __init__.py file. |
| 11 | """ |
| 12 | current_file_path = os.path.abspath(__file__) |
| 13 | current_folder_path = os.path.dirname(current_file_path) |
| 14 | folder_path = os.path.join(current_folder_path, "prompts_raw") |
| 15 | |
| 16 | # If prompts_raw not found in current directory, search parent directories |
| 17 | if not os.path.exists(folder_path): |
| 18 | parent_dir = current_folder_path |
| 19 | while parent_dir != os.path.dirname(parent_dir): # Stop at root directory |
| 20 | parent_dir = os.path.dirname(parent_dir) |
| 21 | test_path = os.path.join(parent_dir, "prompts_raw") |
| 22 | if os.path.exists(test_path): |
| 23 | folder_path = test_path |
| 24 | break |
| 25 | |
| 26 | output_file = os.path.join(folder_path, "__init__.py") |
| 27 | create_python_file_with_texts(folder_path, output_file) |
| 28 | |
| 29 | |
| 30 | def create_python_file_with_texts(folder_path: str, output_file: str) -> None: |
no test coverage detected