File size: 1,715 Bytes
1dd3485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""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.")