14 lines
296 B
Python
14 lines
296 B
Python
import sys
|
|
f = sys.argv[1]
|
|
o = sys.argv[2]
|
|
n = sys.argv[3]
|
|
with open(f, 'r', encoding='utf-8') as fh:
|
|
c = fh.read()
|
|
if o not in c:
|
|
print(f"NOT FOUND: {o[:50]}...")
|
|
sys.exit(1)
|
|
c = c.replace(o, n, 1)
|
|
with open(f, 'w', encoding='utf-8') as fh:
|
|
fh.write(c)
|
|
print(f"OK: patched {f}")
|