(file_path)
| 31 | print(f'Could not convert file {source} due to error: {e}') |
| 32 | |
| 33 | def update_paths(file_path): |
| 34 | try: |
| 35 | with open(file_path, 'r') as file: |
| 36 | data = file.read() |
| 37 | |
| 38 | new_data = data |
| 39 | for image_type in image_types: |
| 40 | new_data = new_data.replace(image_type, '.webp') |
| 41 | |
| 42 | if new_data != data: |
| 43 | with open(file_path, 'w') as file: |
| 44 | file.write(new_data) |
| 45 | except UnicodeDecodeError: |
| 46 | print(f'Could not read file {file_path} due to UnicodeDecodeError.') |
| 47 | |
| 48 | def main(): |
| 49 | current_path = Path('../') |