tests: make 'f' utility import hashlib unconditionally
authorYuya Nishihara <yuya@tcha.org>
Sun, 15 May 2016 10:45:32 +0900
changeset 29233 318534bb5dfd
parent 29232 3dad34e9d134
child 29234 393aef802535
tests: make 'f' utility import hashlib unconditionally It must exist on Python 2.5+.
tests/f
--- a/tests/f	Sun May 15 10:41:01 2016 +0900
+++ b/tests/f	Sun May 15 10:45:32 2016 +0900
@@ -26,6 +26,7 @@
 from __future__ import absolute_import
 
 import glob
+import hashlib
 import optparse
 import os
 import re
@@ -80,17 +81,11 @@
                 else:
                     facts.append('older than %s' % opts.newer)
         if opts.md5 and content is not None:
-            try:
-                from hashlib import md5
-            except ImportError:
-                from md5 import md5
-            facts.append('md5=%s' % md5(content).hexdigest()[:opts.bytes])
+            h = hashlib.md5(content)
+            facts.append('md5=%s' % h.hexdigest()[:opts.bytes])
         if opts.sha1 and content is not None:
-            try:
-                from hashlib import sha1
-            except ImportError:
-                from sha import sha as sha1
-            facts.append('sha1=%s' % sha1(content).hexdigest()[:opts.bytes])
+            h = hashlib.sha1(content)
+            facts.append('sha1=%s' % h.hexdigest()[:opts.bytes])
         if isstdin:
             outfile.write(', '.join(facts) + '\n')
         elif facts: