Spaces:
Build error

WordGame / clean_emojis.py
0Mart00
Verbumix rebrand: emojis removed, multi-jurisdictional legal docs, cookie consent, footer links
9d4e305
Raw History Blame Contribute Delete
7.99 kB
#!/usr/bin/env python3
"""Remove all emojis from the wordgame project and rename WordGame -> Verbumix."""
import os
import re
import sys
# Emoji pattern - covers most emoji unicode ranges
EMOJI_PATTERN = re.compile(
"["
"\U0001F600-\U0001F64F" # emoticons
"\U0001F300-\U0001F5FF" # symbols & pictographs
"\U0001F680-\U0001F6FF" # transport & map
"\U0001F1E0-\U0001F1FF" # flags (iOS)
"\U0001F900-\U0001F9FF" # supplemental symbols
"\U0001FA00-\U0001FA6F" # chess symbols
"\U0001FA70-\U0001FAFF" # symbols extended-A
"\U00002600-\U000026FF" # misc symbols
"\U00002700-\U000027BF" # dingbats
"\U00002300-\U000023FF" # misc technical
"\U00002B50" # star
"\U0000200D" # zero width joiner
"\U0000FE0F" # variation selector-16
"\U0000FE4E0-\U0000FE4FF" # variation selectors
"]+",
re.UNICODE
)
# Additional specific emojis that might be missed
EXTRA_EMOJIS = [
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '',
'', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', 'ยฉ', 'ยฎ', 'โ€ผ', 'โ‰', 'โ„ข', 'โ„น', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', 'โ“‚', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', 'โคด',
'โคต', '', '', '', '', '', '', '', 'ใ€ฐ', 'ใ€ฝ',
'ใŠ—', 'ใŠ™', '๐Ÿ€„', '๐Ÿƒ', '๐Ÿ…ฐ', '๐Ÿ…ฑ', '๐Ÿ…พ', '๐Ÿ…ฟ', '๐Ÿ†Ž', '๐Ÿ†‘',
'๐Ÿ†’', '๐Ÿ†“', '๐Ÿ†”', '๐Ÿ†•', '๐Ÿ†–', '๐Ÿ†—', '๐Ÿ†˜', '๐Ÿ†™', '๐Ÿ†š', '',
'', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '๐Ÿˆ', '๐Ÿˆ‚', '๐Ÿˆš', '๐Ÿˆฏ', '๐Ÿˆฒ',
'๐Ÿˆณ', '๐Ÿˆด', '๐Ÿˆต', '๐Ÿˆถ', '๐Ÿˆท', '๐Ÿˆธ', '๐Ÿˆน', '๐Ÿˆบ', '๐Ÿ‰', '๐Ÿ‰‘',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '',
]
SKIP_DIRS = {'.venv', '.git', '__pycache__', 'node_modules', 'Library', 'Logs', 'Packages'}
SKIP_EXTENSIONS = {'.db', '.db-shm', '.db-wal', '.gguf', '.zip', '.gz', '.png', '.jpg', '.jpeg', '.gif', '.ico', '.svg', '.woff', '.woff2', '.ttf', '.eot'}
BASE_DIR = '/mnt/sdc1/STARTUPS/TEST wordGame'
def clean_content(content):
"""Remove emojis from content."""
# Use regex for most emojis
content = EMOJI_PATTERN.sub('', content)
# Remove any remaining known emojis
for emoji in EXTRA_EMOJIS:
content = content.replace(emoji, '')
return content
def process_file(filepath):
"""Process a single file to remove emojis."""
ext = os.path.splitext(filepath)[1].lower()
if ext in SKIP_EXTENSIONS:
return False
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
except (UnicodeDecodeError, PermissionError):
return False
original = content
content = clean_content(content)
if content != original:
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
return True
return False
def main():
count = 0
for root, dirs, files in os.walk(BASE_DIR):
# Skip unwanted directories
dirs[:] = [d for d in dirs if d not in SKIP_DIRS]
for filename in files:
filepath = os.path.join(root, filename)
if process_file(filepath):
relpath = os.path.relpath(filepath, BASE_DIR)
print(f"Cleaned: {relpath}")
count += 1
print(f"\nTotal files cleaned: {count}")
if __name__ == '__main__':
main()