dfdkflj
This commit is contained in:
24
scripts/normalize_shared_indent.py
Normal file
24
scripts/normalize_shared_indent.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
p = Path('cmdlets/_shared.py')
|
||||
src = p.read_text(encoding='utf-8')
|
||||
lines = src.splitlines(True)
|
||||
changed = False
|
||||
new_lines = []
|
||||
for line in lines:
|
||||
m = re.match(r'^(?P<ws>[ \t]*)', line)
|
||||
ws = m.group('ws') if m else ''
|
||||
if '\t' in ws:
|
||||
new_ws = ws.replace('\t', ' ')
|
||||
new_line = new_ws + line[len(ws):]
|
||||
new_lines.append(new_line)
|
||||
changed = True
|
||||
else:
|
||||
new_lines.append(line)
|
||||
|
||||
if changed:
|
||||
p.write_text(''.join(new_lines), encoding='utf-8')
|
||||
print('Normalized leading tabs to spaces in', p)
|
||||
else:
|
||||
print('No leading tabs found; no changes made')
|
||||
Reference in New Issue
Block a user