Spaces:
Running
Running
| import os | |
| replacements = [ | |
| ("KIA", "KIA"), | |
| ("kia", "kia"), | |
| ("KIA", "KIA"), | |
| ("kia", "kia"), | |
| ("Komanda e Inteligjencës Artificiale", "Komanda e Inteligjencës Artificiale"), | |
| ("Komanda e Inteligjences Artificiale", "Komanda e Inteligjences Artificiale"), | |
| ] | |
| exclude_dirs = [".git", "node_modules", "__pycache__", "dist", "chroma_db", ".pytest_cache", ".vscode"] | |
| def process_file(filepath): | |
| try: | |
| with open(filepath, "r", encoding="utf-8") as f: | |
| content = f.read() | |
| except UnicodeDecodeError: | |
| return | |
| except Exception as e: | |
| print(f"Error reading {filepath}: {e}") | |
| return | |
| new_content = content | |
| for old, new in replacements: | |
| new_content = new_content.replace(old, new) | |
| if new_content != content: | |
| try: | |
| with open(filepath, "w", encoding="utf-8") as f: | |
| f.write(new_content) | |
| print(f"Updated {filepath}") | |
| except Exception as e: | |
| print(f"Error writing to {filepath}: {e}") | |
| if __name__ == "__main__": | |
| count = 0 | |
| for root, dirs, files in os.walk("."): | |
| dirs[:] = [d for d in dirs if d not in exclude_dirs] | |
| for file in files: | |
| if file.endswith((".py", ".js", ".html", ".css", ".md", ".json", ".jsonl", ".txt")): | |
| process_file(os.path.join(root, file)) | |
| count += 1 | |
| print(f"Finished processing {count} files.") | |