diff options
author | David Cournapeau <cournape@gmail.com> | 2009-09-15 01:55:34 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-09-15 01:55:34 +0000 |
commit | c2606d2e797da0a13e2e49f80137dce2baf4e565 (patch) | |
tree | 0c0f768947db39c1407d35bd9da5447fce85a7d8 /numpy | |
parent | 531f1f9206b815c04474023c05bd192643b77297 (diff) | |
download | numpy-c2606d2e797da0a13e2e49f80137dce2baf4e565.tar.gz |
Use hashlib instead of md5 if available in code generator.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/code_generators/genapi.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/core/code_generators/genapi.py b/numpy/core/code_generators/genapi.py index 6e25db011..256a1c8d1 100644 --- a/numpy/core/code_generators/genapi.py +++ b/numpy/core/code_generators/genapi.py @@ -6,7 +6,12 @@ See ``find_function`` for how functions should be formatted, and specified. """ import sys, os, re -import md5 +try: + import hashlib + md5new = hashlib.md5 +except ImportError: + import md5 + md5new = md5.new import textwrap from os.path import join @@ -94,7 +99,7 @@ class Function(object): return '\n'.join(lines) def api_hash(self): - m = md5.new() + m = md5new() m.update(remove_whitespace(self.return_type)) m.update('\000') m.update(self.name) @@ -311,7 +316,7 @@ def fullapi_hash(files): return sorted(d.items(), key=lambda (x, y): (y, x)) a.extend([i[0] for i in sorted_by_values(order)]) - return md5.new(''.join(a)).hexdigest() + return md5new(''.join(a)).hexdigest() # To parse strings like 'hex = checksum' where hex is e.g. 0x1234567F and # checksum a 128 bits md5 checksum (hex format as well) @@ -336,7 +341,7 @@ def main(): tagname = sys.argv[1] order_file = sys.argv[2] functions = get_api_functions(tagname, order_file) - m = md5.new(tagname) + m = md5new(tagname) for func in functions: print func ah = func.api_hash() |