tests/f
changeset 29233 318534bb5dfd
parent 29230 b68af177937d
child 32898 c425b678df7c
equal deleted inserted replaced
29232:3dad34e9d134 29233:318534bb5dfd
    24 """
    24 """
    25 
    25 
    26 from __future__ import absolute_import
    26 from __future__ import absolute_import
    27 
    27 
    28 import glob
    28 import glob
       
    29 import hashlib
    29 import optparse
    30 import optparse
    30 import os
    31 import os
    31 import re
    32 import re
    32 import sys
    33 import sys
    33 
    34 
    78                 if stat.st_mtime >= os.stat(opts.newer).st_mtime:
    79                 if stat.st_mtime >= os.stat(opts.newer).st_mtime:
    79                     facts.append('newer than %s' % opts.newer)
    80                     facts.append('newer than %s' % opts.newer)
    80                 else:
    81                 else:
    81                     facts.append('older than %s' % opts.newer)
    82                     facts.append('older than %s' % opts.newer)
    82         if opts.md5 and content is not None:
    83         if opts.md5 and content is not None:
    83             try:
    84             h = hashlib.md5(content)
    84                 from hashlib import md5
    85             facts.append('md5=%s' % h.hexdigest()[:opts.bytes])
    85             except ImportError:
       
    86                 from md5 import md5
       
    87             facts.append('md5=%s' % md5(content).hexdigest()[:opts.bytes])
       
    88         if opts.sha1 and content is not None:
    86         if opts.sha1 and content is not None:
    89             try:
    87             h = hashlib.sha1(content)
    90                 from hashlib import sha1
    88             facts.append('sha1=%s' % h.hexdigest()[:opts.bytes])
    91             except ImportError:
       
    92                 from sha import sha as sha1
       
    93             facts.append('sha1=%s' % sha1(content).hexdigest()[:opts.bytes])
       
    94         if isstdin:
    89         if isstdin:
    95             outfile.write(', '.join(facts) + '\n')
    90             outfile.write(', '.join(facts) + '\n')
    96         elif facts:
    91         elif facts:
    97             outfile.write('%s: %s\n' % (f, ', '.join(facts)))
    92             outfile.write('%s: %s\n' % (f, ', '.join(facts)))
    98         elif not quiet:
    93         elif not quiet: