UtilitiesPython2/TabnannyChecker.py

Fri, 27 Dec 2013 11:39:08 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 27 Dec 2013 11:39:08 +0100
branch
5_3_x
changeset 3162
5cb6da893fad
parent 2302
f29e9405c851
child 3160
209a07d7e401
permissions
-rw-r--r--

Fixed a severe issue assigning a name to a printer in several dialogs.
(grafted from c91f976a23954e304688ce67d83e480a407ac4d2)

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the indentation check for Python 2.
"""

import sys

import Tabnanny

from Tools import readEncodedFile, normalizeCode

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "ERROR"
        print ""
        print ""
        print "No file name given."
    else:
        filename = sys.argv[-1]
        try:
            codestring = readEncodedFile(filename)[0]
            codestring = normalizeCode(codestring)
            
            nok, fname, line, error = Tabnanny.check(filename, codestring)
        except IOError, msg:
            # fake an indentation error
            nok, fname, line, error = \
                True, filename, "1", "I/O Error: %s" % unicode(msg)
        
        if nok:
            print "ERROR"
        else:
            print "NO_ERROR"
        print fname
        print line
        print error
    
    sys.exit(0)

#
# eflag: FileType = Python2

eric ide

mercurial