Ticket #8 (closed enhancement: fixed)
hook for reindentation of Python code
|Reported by:||zooko@…||Owned by:||lele|
Somebody please take this pre-commit hook and fix it. It appears to work "some of the time" for me.
You have to find reindent.py in your Python distribution and put it in your python path.
def reindent_em(wd, changeset): import reindent import os for entry in changeset.entries: fname = os.path.join(wd.basedir, entry.name) try: if fname[-3:] == '.py': reindent.check(fname) except Exception, le: print "got an exception from attempt to reindent (maybe that file wasn't Python code?): changeset entry: %s, exception: %s %s %s" % (entry, type(le), repr(le), hasattr(le, 'args') and le.args,) raise le return True