Use hashlib module instead of md5 if it is present.
md5 module is deprecated since Python 2.5 and we'd better off using hashlib instead. Review URL: http://codereview.chromium.org/3026030 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5143 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
10b847eb55
commit
bc01445830
@ -27,8 +27,14 @@
|
|||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
try:
|
||||||
|
import hashlib
|
||||||
|
md5er = hashlib.md5
|
||||||
|
except ImportError, e:
|
||||||
|
import md5
|
||||||
|
md5er = md5.new
|
||||||
|
|
||||||
|
|
||||||
import md5
|
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
from os.path import abspath, join, dirname, basename, exists
|
from os.path import abspath, join, dirname, basename, exists
|
||||||
@ -126,7 +132,7 @@ class FileContentsCache(object):
|
|||||||
for file in files:
|
for file in files:
|
||||||
try:
|
try:
|
||||||
handle = open(file, "r")
|
handle = open(file, "r")
|
||||||
file_sum = md5.new(handle.read()).digest()
|
file_sum = md5er(handle.read()).digest()
|
||||||
if not file in self.sums or self.sums[file] != file_sum:
|
if not file in self.sums or self.sums[file] != file_sum:
|
||||||
changed_or_new.append(file)
|
changed_or_new.append(file)
|
||||||
self.sums[file] = file_sum
|
self.sums[file] = file_sum
|
||||||
|
Loading…
Reference in New Issue
Block a user