清理全库行尾空格与文件尾换行(pre-commit 自动修复基线)
This commit is contained in:
@@ -122,16 +122,16 @@ for fname, file_fixes in fixes.items():
|
||||
raw = f.read()
|
||||
text = raw.decode('utf-8', errors='replace')
|
||||
before = text.count(rep)
|
||||
|
||||
|
||||
for needle, replacement in file_fixes:
|
||||
while needle in text:
|
||||
text = text.replace(needle, replacement)
|
||||
|
||||
|
||||
after = text.count(rep)
|
||||
fixed = before - after
|
||||
total_fixed += fixed
|
||||
print('{}: fixed {} ({} -> {})'.format(fname, fixed, before, after))
|
||||
|
||||
|
||||
with open(path, 'wb') as f:
|
||||
f.write(text.encode('utf-8'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user