aegis-graph / scratch /global_purify.py
ACLASCollege's picture
FINAL PROFESSIONALIZATION: Synchronized with GitHub sovereign standards.
05a5750 verified
import os
root_path = r'd:\aicoding\kaiyuan\v2'
# Aggressive Byte-level replacement map
REPLACEMENTS = {
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xba\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb8': b'\xf0\x9f\x87\xba\xf0\x9f\x87\xb8', # US Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xad\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb0': b'\xf0\x9f\x87\xad\xf0\x9f\x87\xb0', # HK Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xaa\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb8': b'\xf0\x9f\x87\xaa\xf0\x9f\x87\xb8', # ES Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xab\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb7': b'\xf0\x9f\x87\xab\xf0\x9f\x87\xb7', # FR Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xa9\xc3\xb0\xc2\x9f\xc2\x87\xc2\xaa': b'\xf0\x9f\x87\xa9\xf0\x9f\x87\xea', # DE Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xaf\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb5': b'\xf0\x9f\x87\xaf\xf0\x9f\x87\xb5', # JP Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb0\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb7': b'\xf0\x9f\x87\xb0\xf0\x9f\x87\xb7', # KR Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb8\xc3\xb0\xc2\x9f\xc2\x87\xc2\xa6': b'\xf0\x9f\x87\xb8\xf0\x9f\x87\xa6', # SA Flag
b'\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb5\xc3\xb0\xc2\x9f\xc2\x87\xc2\xb9': b'\xf0\x9f\x87\xb5\xf0\x9f\x87\xb9', # PT Flag
b'\xc3\xa2\xc2\x80\xc2\x94': b'\xe2\x80\x94', # em-dash
b'\xc3\xa2\xc2\x80\xc2\xa2': b'\xe2\x80\xa2', # bullet
b'\xc3\x82\xc2\xa9': b'\xc2\xa9', # copyright
b'\xc3\x83\xc2\xa9': b'\xc3\xa9', # e-acute (Français)
b'\xc3\x83\xc2\xb1': b'\xc3\xb1', # n-tilde (Español)
b'\xef\xbf\xbd': b'' # Remove replacement chars
}
def deep_purify():
for root, dirs, files in os.walk(root_path):
if any(x in root for x in ['.git', '__pycache__', 'scratch']): continue
for file in files:
if file.endswith(('.html', '.md', '.js', '.json', '.txt')):
filepath = os.path.join(root, file)
print(f"Deep Purifying: {filepath}")
with open(filepath, 'rb') as f:
data = f.read()
original_data = data
for old, new in REPLACEMENTS.items():
data = data.replace(old, new)
if data != original_data:
with open(filepath, 'wb') as f:
f.write(data)
print(f" [FIXED] {filepath}")
if __name__ == "__main__":
deep_purify()
print("\n--- GLOBAL ASSET PURIFICATION COMPLETE ---")