Show More
@@ -26,6 +26,7 This can be used instead of tools like: | |||||
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 | |
@@ -80,17 +81,11 def visit(opts, filenames, outfile): | |||||
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: |
General Comments 0
You need to be logged in to leave comments.
Login now