Guido van Rossum schrieb:
On 4/25/07, Georg Brandl <[EMAIL PROTECTED]> wrote:
Well, there are editors that don't intelligently strip whitespace, so that
people using them would be constantly pained by such a hook.
And they should. There really is no excuse for letting one developer's
poor choice of tools cause later grief for all other developers.
Okay, attached is a pre-commit hook script for that purpose.
Georg
--
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
#!/usr/bin/env python
SVNLOOK = '/usr/bin/svnlook'
SCRIPTS_PATH = '/home/gbr/devel/python/Tools/scripts'
import sys
sys.path.insert(0, SCRIPTS_PATH)
_, repos, txn = sys.argv
from subprocess import Popen, PIPE
from reindent import Reindenter
from StringIO import StringIO
def get_output(*command):
popen = Popen(command, stdout=PIPE)
stdout = popen.communicate()[0]
if popen.returncode:
sys.exit(1)
else:
return stdout
bad = 0
for line in get_output(SVNLOOK, 'changed', '-t', txn, repos).splitlines():
filename = line[4:].strip()
if not filename[-3:] == '.py': continue
content = StringIO(get_output(SVNLOOK, 'cat', '-t', txn, repos, filename))
reindenter = Reindenter(content)
if reindenter.run():
print >>sys.stderr, "file %s is not whitespace-normalized" % filename
bad += 1
if bad:
sys.exit(1)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com