--- a/updaterevision.py Sun Nov 28 23:53:23 2021 +0200 +++ b/updaterevision.py Mon Dec 06 00:29:47 2021 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # coding: utf-8 # # Copyright 2015 Teemu Piippo @@ -30,7 +30,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -import md5, sys +import hashlib, sys class OutputFile: def __init__ (self, filename): @@ -47,10 +47,10 @@ self.body += a def save (self): - checksum = md5.new (self.body).hexdigest() + checksum = hashlib.md5(self.body.encode()).hexdigest() if checksum == self.oldsum: - print '%s is up to date' % self.filename + print('%s is up to date' % self.filename) return False with open (self.filename, "w") as fp: @@ -63,12 +63,12 @@ from datetime import datetime if len (sys.argv) != 2: - print 'usage: %s <output>' % sys.argv[0] + print('usage: %s <output>' % sys.argv[0]) quit (1) f = OutputFile (sys.argv[1]) data = subprocess.check_output (['hg', 'log', '-r.', '--template', - '{node|short} {branch} {date|hgdate}']).replace ('\n', '').split (' ') + '{node|short} {branch} {date|hgdate}']).decode().replace ('\n', '').split (' ') rev = data[0] branch = data[1] @@ -79,7 +79,7 @@ if len(rev) > 7: rev = rev[0:7] - if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+': + if subprocess.check_output (['hg', 'id', '-n']).decode().replace ('\n', '')[-1] == '+': rev += '+' f.write ('#define HG_NODE "%s"\n' % rev) @@ -88,7 +88,7 @@ f.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y')) f.write ('#define HG_DATE_TIME %d\n' % int (timestamp)) if f.save(): - print '%s updated to %s' % (f.filename, rev) + print('%s updated to %s' % (f.filename, rev)) if __name__ == '__main__': - main() \ No newline at end of file + main()