Spaces:
Paused
Paused
Download src/data/check_structure.py from Demosthene-OR/rakuten: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Demosthene-OR/rakuten/resolve/main/src/data/check_structure.py
- Command line
-
hf download hf://spaces/Demosthene-OR/rakuten/src/data/check_structure.py
-
curl -L -o check_structure.py https://huggingface.co/spaces/Demosthene-OR/rakuten/resolve/main/src/data/check_structure.py
1.13 kB
| import os | |
| def check_existing_file(file_path): | |
| '''Check if a file already exists. If it does, ask if we want to overwrite it.''' | |
| if os.path.isfile(file_path): | |
| while True: | |
| response = input(f"File {os.path.basename(file_path)} already exists. Do you want to overwrite it? (y/n): ") | |
| if response.lower() == 'y': | |
| return True | |
| elif response.lower() == 'n': | |
| return False | |
| else: | |
| print("Invalid response. Please enter 'y' or 'n'.") | |
| else: | |
| return True | |
| def check_existing_folder(folder_path): | |
| '''Check if a folder already exists. If it does, ask if we want to create it.''' | |
| if os.path.exists(folder_path) == False : | |
| while True: | |
| response = input(f"{os.path.basename(folder_path)} doesn't exists. Do you want to create it? (y/n): ") | |
| if response.lower() == 'y': | |
| return True | |
| elif response.lower() == 'n': | |
| return False | |
| else: | |
| print("Invalid response. Please enter 'y' or 'n'.") | |
| else: | |
| return False |