|
1 #!/usr/bin/env python2 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 Module implementing the indentation check for Python 2. |
|
9 """ |
|
10 |
|
11 import sys |
|
12 |
|
13 import Tabnanny |
|
14 |
|
15 from Tools import readEncodedFile, normalizeCode |
|
16 |
|
17 if __name__ == "__main__": |
|
18 if len(sys.argv) < 2: |
|
19 print "ERROR" |
|
20 print "" |
|
21 print "" |
|
22 print "No file name given." |
|
23 else: |
|
24 filename = sys.argv[-1] |
|
25 try: |
|
26 codestring = readEncodedFile(filename)[0] |
|
27 codestring = normalizeCode(codestring) |
|
28 |
|
29 nok, fname, line, error = Tabnanny.check(filename, codestring) |
|
30 except IOError, msg: |
|
31 # fake an indentation error |
|
32 nok, fname, line, error = \ |
|
33 True, filename, "1", "I/O Error: %s" % unicode(msg) |
|
34 |
|
35 if nok: |
|
36 print "ERROR" |
|
37 else: |
|
38 print "NO_ERROR" |
|
39 print fname |
|
40 print line |
|
41 print error |
|
42 |
|
43 sys.exit(0) |
|
44 |
|
45 # |
|
46 # eflag: FileType = Python2 |