Commit 700655a2 authored by Jérome Perrin's avatar Jérome Perrin

update-hash: python3 support

also mention automatic installation method
parent ede3f1a1
#!/usr/bin/env python2 #!/usr/bin/env python
""" """
Suggested installation: Helper script to update buildout.hash.cfg
Usage:
$ ./update-hash [BUILDOUT_HASH_CFG]
Automatic installation using husky, from the root of the repository:
$ npm install
Manual installation:
$ cp update-hash .git/hooks/ $ cp update-hash .git/hooks/
$ $EDITOR .git/hooks/pre-commit $ $EDITOR .git/hooks/pre-commit
...@@ -36,7 +44,6 @@ import hashlib ...@@ -36,7 +44,6 @@ import hashlib
import os import os
import shutil import shutil
import sys import sys
import tempfile
# Note: this is an intentionally very restrictive and primitive # Note: this is an intentionally very restrictive and primitive
# ConfigParser-ish parser. # ConfigParser-ish parser.
...@@ -62,7 +69,11 @@ def main(): ...@@ -62,7 +69,11 @@ def main():
try: try:
outfile = os.fdopen(outfile_fd, 'w') outfile = os.fdopen(outfile_fd, 'w')
write = outfile.write write = outfile.write
nextLine = iter(infile).next if sys.version_info <= (3,):
nextLine = iter(infile).next
else:
nextLine = iter(infile).__next__
while True: while True:
try: try:
line = nextLine() line = nextLine()
...@@ -80,7 +91,8 @@ def main(): ...@@ -80,7 +91,8 @@ def main():
os.path.join( os.path.join(
infile_dirname, infile_dirname,
*hash_file_path.split('/') *hash_file_path.split('/')
) ),
'rb',
).read() ).read()
).hexdigest(), ).hexdigest(),
eol, eol,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment