aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2014-08-23 01:31:41 +0200
committerLaurent Bachelier <laurent@bachelier.name>2014-08-23 01:31:41 +0200
commitfc58c5ec908464a776141b7ef52d62cd6001d5ef (patch)
tree0b0822599ff54bac6a9f22b77c3d580b797e0915
parentSimplify/fix argparse config (diff)
downloadrencon-fc58c5ec908464a776141b7ef52d62cd6001d5ef.tar.xz
Modernize code
-rwxr-xr-xrencon11
1 files changed, 6 insertions, 5 deletions
diff --git a/rencon b/rencon
index 30ab44f..54946ac 100755
--- a/rencon
+++ b/rencon
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import absolute_import, unicode_literals, print_function
import argparse
import hashlib
@@ -19,11 +20,11 @@ if __name__ == '__main__':
help="do not rename, just print")
args = parser.parse_args()
- print "Renaming with mask: %s" % args.mask
+ print("Renaming with mask: %s" % args.mask)
mask = Template(args.mask)
for f in args.files:
if not os.path.exists(f):
- print >>sys.stderr, "File %s does not exists." % f
+ print("File %s does not exists." % f, file=sys.stderr)
else:
with open(f) as fp:
h = hashlib.sha1(fp.read()).hexdigest()
@@ -31,10 +32,10 @@ if __name__ == '__main__':
name = mask.substitute(hash=h, ext=ext)
dest = os.path.join(os.path.dirname(f), name)
if os.path.basename(f) == name:
- print "OK %s" % name
+ print("OK %s" % name)
else:
- print "`%s' -> `%s'" % (f, dest)
+ print("`%s' -> `%s'" % (f, dest))
if os.path.exists(dest):
- print >>sys.stderr, "Destination %s already exists." % dest
+ print("Destination %s already exists." % dest, file=sys.stderr)
elif not args.pretend:
os.rename(f, dest)