corpusdb / patch_sql_block.py
mrsavage1's picture
Upload 10 files
6fe9fd7 verified
raw
history blame contribute delete
656 Bytes
d = open('app/ui.py', 'rb').read()
old = b"sampleRows = text.split('\\n').filter(l => l.trim() && !l.startsWith('--')).slice(0, 5);\r\n headers = ['(SQL dump \xe2\x80\x94 columns detected automatically)'];"
new = b'sampleRows = text.split(String.fromCharCode(10)).filter(l => l.trim() && !l.startsWith("--")).slice(0, 5);\r\n headers = ["(SQL dump - columns detected automatically)"];'
print('found:', old in d)
if old in d:
d2 = d.replace(old, new)
open('app/ui.py', 'wb').write(d2)
print('written, size:', len(d2))
else:
# show nearby context
i = d.find(b'sampleRows = text.split')
print('nearby:', repr(d[i:i+120]))