Spaces:
Sleeping
Sleeping
| """Strip non-ASCII characters from all project source files so openenv push works.""" | |
| import os | |
| FILES = [ | |
| "models.py", | |
| "inference.py", | |
| "server/openenv_jayesh_environment.py", | |
| "README.md", | |
| ] | |
| REPLACEMENTS = { | |
| "\u2014": "--", # em dash | |
| "\u2013": "-", # en dash | |
| "\u2212": "-", # minus sign | |
| "\u2265": ">=", # greater-or-equal | |
| "\u2264": "<=", # less-or-equal | |
| "\u2192": "->", # right arrow | |
| "\u2190": "<-", # left arrow | |
| "\u2026": "...", # ellipsis | |
| "\u25ba": "->", # filled right triangle | |
| "\u25c4": "<-", # filled left triangle | |
| "\u251c": "+", # box drawing tee | |
| "\u2500": "-", # box drawing horizontal | |
| "\u2514": "+", # box drawing corner | |
| "\u2019": "'", # right single quote | |
| "\u2018": "'", # left single quote | |
| "\u201c": '"', # left double quote | |
| "\u201d": '"', # right double quote | |
| } | |
| for fpath in FILES: | |
| if not os.path.exists(fpath): | |
| print(f"SKIP (not found): {fpath}") | |
| continue | |
| with open(fpath, "r", encoding="utf-8") as f: | |
| content = f.read() | |
| original = content | |
| for old, new in REPLACEMENTS.items(): | |
| content = content.replace(old, new) | |
| remaining = [(i, hex(ord(c)), repr(c)) for i, c in enumerate(content) if ord(c) > 127] | |
| if remaining: | |
| print(f"WARN {fpath}: {len(remaining)} non-ASCII chars remain:") | |
| for pos, hx, ch in remaining[:10]: | |
| print(f" pos={pos} {hx} {ch}") | |
| else: | |
| with open(fpath, "w", encoding="utf-8") as f: | |
| f.write(content) | |
| status = "changed" if content != original else "already clean" | |
| print(f"OK {fpath}: {status}") | |
| print("\nDone. All files processed.") | |