diff options
author | Laurent Bachelier <laurent@bachelier.name> | 2014-08-23 01:31:41 +0200 |
---|---|---|
committer | Laurent Bachelier <laurent@bachelier.name> | 2014-08-23 01:31:41 +0200 |
commit | fc58c5ec908464a776141b7ef52d62cd6001d5ef (patch) | |
tree | 0b0822599ff54bac6a9f22b77c3d580b797e0915 /rencon | |
parent | Simplify/fix argparse config (diff) | |
download | rencon-fc58c5ec908464a776141b7ef52d62cd6001d5ef.tar.xz |
Modernize code
Diffstat (limited to 'rencon')
-rwxr-xr-x | rencon | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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) |