|
Revision 2412, 1.1 kB
(checked in by paul, 2 years ago)
|
Set end of line style to native for several missed ones.
|
- Property svn:eol-style set to
native
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
#!/usr/bin/env python |
|---|
| 2 |
import os |
|---|
| 3 |
|
|---|
| 4 |
culprits = {} |
|---|
| 5 |
culpritLineCount = 0 |
|---|
| 6 |
|
|---|
| 7 |
for root, dirs, files in os.walk('.'): |
|---|
| 8 |
for fname in files: |
|---|
| 9 |
if fname[-3:] == ".py": |
|---|
| 10 |
fullFile = os.path.join(root, fname) |
|---|
| 11 |
f = open(fullFile) |
|---|
| 12 |
lineNum = 0 |
|---|
| 13 |
for l in f.readlines(): |
|---|
| 14 |
lineNum += 1 |
|---|
| 15 |
l = l.replace("\t", "") |
|---|
| 16 |
if len(l) > 0 and l[0] == " ": |
|---|
| 17 |
culpritLineCount += 1 |
|---|
| 18 |
lineNums = culprits.setdefault(fullFile, []) |
|---|
| 19 |
lineNums.append(lineNum) |
|---|
| 20 |
if culprits.has_key(fullFile): |
|---|
| 21 |
print "! => %s (%s)" % (fullFile, len(culprits[fullFile])) |
|---|
| 22 |
|
|---|
| 23 |
print """ |
|---|
| 24 |
There are %s file(s) with mixed or space-only indentation, and a total of |
|---|
| 25 |
%s line(s). We'll now cycle through the lines in vim, one by one, so that |
|---|
| 26 |
you may edit them as needed. Due to this script being kind of stupid, you |
|---|
| 27 |
shouldn't add or remove lines in the files, just fix the problem. |
|---|
| 28 |
""" % (len(culprits), culpritLineCount) |
|---|
| 29 |
|
|---|
| 30 |
print "\nContinue? (y/[N])", |
|---|
| 31 |
ret = raw_input() |
|---|
| 32 |
if ret.lower() == "y": |
|---|
| 33 |
for fileName, lines in culprits.items(): |
|---|
| 34 |
for line in lines: |
|---|
| 35 |
os.system("vi %s +%s" % (fileName, line)) |
|---|
| 36 |
# print "%s: %s" % (k, v) |
|---|