File no-python2.patch of Package dd_rescue

---
 calchmac.py |   46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

--- a/calchmac.py
+++ b/calchmac.py
@@ -1,43 +1,39 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import hashlib
 import hmac
 import sys
 
 if len(sys.argv) < 4:
-	print >>sys.stderr, "Usage: calchmac.py ALG PASS FILE [FILE [..]]"
-	sys.exit(1)
+    print("Usage: calchmac.py ALG PASS FILE [FILE [..]]", file=sys.stderr)
+    sys.exit(1)
 
 algtbl = (("md5", hashlib.md5),
-	  ("sha1", hashlib.sha1),
-	  ("sha256", hashlib.sha256),
-	  ("sha224", hashlib.sha224),
-	  ("sha512", hashlib.sha512),
-	  ("sha384", hashlib.sha384))
+          ("sha1", hashlib.sha1),
+          ("sha256", hashlib.sha256),
+          ("sha224", hashlib.sha224),
+          ("sha512", hashlib.sha512),
+          ("sha384", hashlib.sha384))
 
 
 alg = sys.argv[1]
 pwd = sys.argv[2]
-#salt1 = salt + "\0\0\0\x01"
+# salt1 = salt + "\0\0\0\x01"
 algo = None
 
 for (anm, aob) in algtbl:
-	if alg == anm:
-		algo = aob
-		break
+    if alg == anm:
+        algo = aob
+        break
 
 if not algo:
-	print >>sys.stderr, "Hash algorithm %s not found!" % alg
-	sys.exit(2)
+    print("Hash algorithm {} not found!".format(alg), file=sys.stderr)
+    sys.exit(2)
 
-#hmf = open("HMACS.%s" % alg, "w")
+# hmf = open("HMACS.%s" % alg, "w")
 for fnm in sys.argv[3:]:
-	f = file(fnm, "rb")
-	if not f:
-		print >>sys.stderr, "Could not open %s" % fnm
-		sys.exit(3)
-	#print fnm
-	fcont = f.read()
-	hm = hmac.HMAC(pwd, fcont, algo)
-	#print >>hmf, "%s *%s" % (hm.hexdigest(), fnm)
-	print "%s *%s" %(hm.hexdigest(), fnm)
-
+    with open(fnm, "rb") as f:
+        # print fnm
+        fcont = f.read()
+        hm = hmac.HMAC(pwd, fcont, algo)
+        # print >>hmf, "%s *%s" % (hm.hexdigest(), fnm)
+        print("{} *{}".format(hm.hexdigest(), fnm))
openSUSE Build Service is sponsored by