Spaces:
Paused
Paused
| import os | |
| import re | |
| def replace_in_file(filepath): | |
| try: | |
| with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: | |
| content = f.read() | |
| # Comprehensive replacements | |
| replacements = [ | |
| (r'DeepPersona', 'DeepPersona'), | |
| (r'deeppersona', 'deeppersona'), | |
| (r'DeepPersona', 'DeepPersona'), | |
| (r'deeppersona', 'deeppersona'), | |
| (r'DeepPersonaFactory', 'DeepPersonaFactory'), | |
| (r'DeepWorld', 'DeepWorld'), | |
| (r'DeepSocialNetwork', 'DeepSocialNetwork'), | |
| (r'DeepMentalFaculty', 'DeepMentalFaculty'), | |
| (r'DeepMemory', 'DeepMemory'), | |
| (r'DeepTool', 'DeepTool'), | |
| (r'DeepStory', 'DeepStory'), | |
| (r'DeepEnricher', 'DeepEnricher'), | |
| (r'DeepStyler', 'DeepStyler'), | |
| (r'DeepValidator', 'DeepValidator'), | |
| (r'DeepWordProcessor', 'DeepWordProcessor'), | |
| (r'DeepCalendar', 'DeepCalendar'), | |
| (r'DeepToolUse', 'DeepToolUse'), | |
| (r'DeepPersonaFactory', 'DeepPersonaFactory'), | |
| (r'DeepPersonaValidator', 'DeepPersonaValidator'), | |
| (r'DeepSocialWorld', 'DeepSocialWorld'), | |
| # Lowercase versions for file names or variables | |
| (r'deep_world', 'deep_world'), | |
| (r'deep_social_network', 'deep_social_network'), | |
| (r'social_deep_world', 'social_deep_world'), | |
| (r'deep_persona_factory', 'deep_persona_factory'), | |
| (r'deep_persona_factory_base', 'deep_persona_factory_base'), | |
| (r'deep_persona', 'deep_persona'), | |
| (r'deep_styler', 'deep_styler'), | |
| (r'deep_enricher', 'deep_enricher'), | |
| (r'deep_story', 'deep_story'), | |
| (r'deep_tool', 'deep_tool'), | |
| (r'deep_calendar', 'deep_calendar'), | |
| (r'deep_word_processor', 'deep_word_processor'), | |
| (r'deep_personaa', 'deep_persona'), | |
| # Space or human readable | |
| (r'Deep Persona', 'Deep Persona'), | |
| (r'deep persona', 'deep persona') | |
| ] | |
| new_content = content | |
| for pattern, replacement in replacements: | |
| new_content = re.sub(pattern, replacement, new_content) | |
| if new_content != content: | |
| with open(filepath, 'w', encoding='utf-8') as f: | |
| f.write(new_content) | |
| print(f"Updated: {filepath}") | |
| except Exception as e: | |
| print(f"Error processing {filepath}: {e}") | |
| def main(): | |
| exclude_dirs = {'.git', '__pycache__', '.pytest_cache', 'venv'} | |
| # Including .mustache and .json which were missed or had leftovers | |
| target_files = {'.py', '.md', '.ini', '.toml', '.json', '.mustache', '.txt'} | |
| for root, dirs, files in os.walk('.'): | |
| dirs[:] = [d for d in dirs if d not in exclude_dirs] | |
| for file in files: | |
| ext = os.path.splitext(file)[1] | |
| if ext in target_files: | |
| replace_in_file(os.path.join(root, file)) | |
| if __name__ == "__main__": | |
| main() | |