# -*- coding: utf-8 -*-
|
import io
|
path = r'C:\Users\jcxiong\Documents\Codex\MyProject\trafficAudit\traffic-audit-server\src\main\java\com\trafficaudit\reportexport\service\ReportExportService.java'
|
with io.open(path, encoding='utf-8') as f:
|
content = f.read()
|
has_crlf = '\r\n' in content
|
lines = content.split('\n')
|
fixed = 0
|
for i, l in enumerate(lines):
|
if 'rowIdx = writeRankHead(' in l and i+1 < len(lines) and lines[i+1].strip() == 'int rowIdx = 3;':
|
lines[i], lines[i+1] = lines[i+1], lines[i]
|
fixed += 1
|
print('swapped pairs:', fixed)
|
assert fixed == 2
|
new_content = '\n'.join(lines)
|
if has_crlf:
|
new_content = new_content.replace('\n', '\r\n')
|
with io.open(path, 'w', encoding='utf-8', newline='') as f:
|
f.write(new_content)
|
print('saved')
|