UtilitiesPython2/TabnannyChecker.py

Sun, 29 Jan 2012 17:59:34 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 29 Jan 2012 17:59:34 +0100
changeset 1586
b3e34806b734
parent 1509
c0b5e693b0eb
child 2302
f29e9405c851
permissions
-rw-r--r--

Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.

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

# Copyright (c) 2011 - 2012 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