aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2020-01-19 19:03:00 +0100
committerLaurent Bachelier <laurent@bachelier.name>2020-01-19 19:04:33 +0100
commit54a836119698a1379ec6c25c0de97cd6afe98682 (patch)
tree6053aad1ebfb2e1423cbffe8f97c0ab294a6d3f3
parentLicense as MIT (diff)
downloadrencon-54a836119698a1379ec6c25c0de97cd6afe98682.tar.xz
Python 3 compatibility (and default)HEADmaster
-rwxr-xr-xrencon6
1 files changed, 3 insertions, 3 deletions
diff --git a/rencon b/rencon
index 72f0aac..1a2640a 100755
--- a/rencon
+++ b/rencon
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, print_function, unicode_literals
import argparse
@@ -22,7 +22,7 @@ def rename(fpath, mask, algorithm, abbrev=None, out=sys.stdout, err=sys.stderr):
if not os.path.exists(fpath):
print("File %s does not exists." % fpath, file=err)
else:
- with open(fpath) as fp:
+ with open(fpath, 'rb') as fp:
hasher = getattr(hashlib, algorithm)
hsh = hashfile(hasher, fp).hexdigest()
if abbrev:
@@ -60,7 +60,7 @@ if __name__ == '__main__':
parser.add_argument('-p', '--pretend', action='store_true',
help="do not rename, just print")
parser.add_argument('-a', '--algorithm',
- help="hash algorithm", choices=hashlib.algorithms, default='sha1')
+ help="hash algorithm", choices=hashlib.algorithms_available, default='sha1')
parser.add_argument('-b', '--abbrev', metavar='N', type=abbrev,
help="use the first N digits", default=None)