Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- final_branding.py +74 -0
final_branding.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
def replace_in_file(filepath):
|
| 5 |
+
try:
|
| 6 |
+
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
|
| 7 |
+
content = f.read()
|
| 8 |
+
|
| 9 |
+
# Comprehensive replacements
|
| 10 |
+
replacements = [
|
| 11 |
+
(r'DeepPersona', 'DeepPersona'),
|
| 12 |
+
(r'deeppersona', 'deeppersona'),
|
| 13 |
+
(r'DeepPersona', 'DeepPersona'),
|
| 14 |
+
(r'deeppersona', 'deeppersona'),
|
| 15 |
+
(r'DeepPersonaFactory', 'DeepPersonaFactory'),
|
| 16 |
+
(r'DeepWorld', 'DeepWorld'),
|
| 17 |
+
(r'DeepSocialNetwork', 'DeepSocialNetwork'),
|
| 18 |
+
(r'DeepMentalFaculty', 'DeepMentalFaculty'),
|
| 19 |
+
(r'DeepMemory', 'DeepMemory'),
|
| 20 |
+
(r'DeepTool', 'DeepTool'),
|
| 21 |
+
(r'DeepStory', 'DeepStory'),
|
| 22 |
+
(r'DeepEnricher', 'DeepEnricher'),
|
| 23 |
+
(r'DeepStyler', 'DeepStyler'),
|
| 24 |
+
(r'DeepValidator', 'DeepValidator'),
|
| 25 |
+
(r'DeepWordProcessor', 'DeepWordProcessor'),
|
| 26 |
+
(r'DeepCalendar', 'DeepCalendar'),
|
| 27 |
+
(r'DeepToolUse', 'DeepToolUse'),
|
| 28 |
+
(r'DeepPersonaFactory', 'DeepPersonaFactory'),
|
| 29 |
+
(r'DeepPersonaValidator', 'DeepPersonaValidator'),
|
| 30 |
+
(r'DeepSocialWorld', 'DeepSocialWorld'),
|
| 31 |
+
# Lowercase versions for file names or variables
|
| 32 |
+
(r'deep_world', 'deep_world'),
|
| 33 |
+
(r'deep_social_network', 'deep_social_network'),
|
| 34 |
+
(r'social_deep_world', 'social_deep_world'),
|
| 35 |
+
(r'deep_persona_factory', 'deep_persona_factory'),
|
| 36 |
+
(r'deep_persona_factory_base', 'deep_persona_factory_base'),
|
| 37 |
+
(r'deep_persona', 'deep_persona'),
|
| 38 |
+
(r'deep_styler', 'deep_styler'),
|
| 39 |
+
(r'deep_enricher', 'deep_enricher'),
|
| 40 |
+
(r'deep_story', 'deep_story'),
|
| 41 |
+
(r'deep_tool', 'deep_tool'),
|
| 42 |
+
(r'deep_calendar', 'deep_calendar'),
|
| 43 |
+
(r'deep_word_processor', 'deep_word_processor'),
|
| 44 |
+
(r'deep_personaa', 'deep_persona'),
|
| 45 |
+
# Space or human readable
|
| 46 |
+
(r'Deep Persona', 'Deep Persona'),
|
| 47 |
+
(r'deep persona', 'deep persona')
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
new_content = content
|
| 51 |
+
for pattern, replacement in replacements:
|
| 52 |
+
new_content = re.sub(pattern, replacement, new_content)
|
| 53 |
+
|
| 54 |
+
if new_content != content:
|
| 55 |
+
with open(filepath, 'w', encoding='utf-8') as f:
|
| 56 |
+
f.write(new_content)
|
| 57 |
+
print(f"Updated: {filepath}")
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f"Error processing {filepath}: {e}")
|
| 60 |
+
|
| 61 |
+
def main():
|
| 62 |
+
exclude_dirs = {'.git', '__pycache__', '.pytest_cache', 'venv'}
|
| 63 |
+
# Including .mustache and .json which were missed or had leftovers
|
| 64 |
+
target_files = {'.py', '.md', '.ini', '.toml', '.json', '.mustache', '.txt'}
|
| 65 |
+
|
| 66 |
+
for root, dirs, files in os.walk('.'):
|
| 67 |
+
dirs[:] = [d for d in dirs if d not in exclude_dirs]
|
| 68 |
+
for file in files:
|
| 69 |
+
ext = os.path.splitext(file)[1]
|
| 70 |
+
if ext in target_files:
|
| 71 |
+
replace_in_file(os.path.join(root, file))
|
| 72 |
+
|
| 73 |
+
if __name__ == "__main__":
|
| 74 |
+
main()
|