def get_module_hash(src_code, key):
 to_hash = [l.strip() for l in src_code.split('\n')]
 if key[0]:
  to_hash += list(map(str, key[0]))
 c_link_key = key[1]
 error_msg = 'This should not happen unless someone modified the code that defines the CLinker key, in which case you should ensure this piece of code is still valid (and this AssertionError may be removed or modified to accomodate this change)'
 assert (c_link_key[0] == 'CLinker.cmodule_key'), error_msg
 for key_element in c_link_key[1:]:
  if isinstance(key_element, tuple):
   to_hash += list(key_element)
  elif isinstance(key_element, string_types):
   if key_element.startswith('md5:'):
    break
   elif (key_element.startswith('NPY_ABI_VERSION=0x') or key_element.startswith('c_compiler_str=')):
    to_hash.append(key_element)
   else:
    raise AssertionError(error_msg)
  else:
   raise AssertionError(error_msg)
 return hash_from_code('\n'.join(to_hash))

def get_module_hash ( src_code , key ) : to_hash = [ l . strip ( ) for l in src_code . split ( '\n' ) ] if key [ 0 ] : to_hash += list ( map ( str , key [ 0 ] ) ) c_link_key = key [ 1 ] error_msg = 'This should not happen unless someone modified the code that defines the CLinker key, in which case you should ensure this piece of code is still valid (and this AssertionError may be removed or modified to accomodate this change)' assert ( c_link_key [ 0 ] == 'CLinker.cmodule_key' ) , error_msg for key_element in c_link_key [ 1 : ] : if isinstance ( key_element , tuple ) : to_hash += list ( key_element ) elif isinstance ( key_element , string_types ) : if key_element . startswith ( 'md5:' ) : break elif ( key_element . startswith ( 'NPY_ABI_VERSION=0x' ) or key_element . startswith ( 'c_compiler_str=' ) ) : to_hash . append ( key_element ) else : raise AssertionError ( error_msg ) else : raise AssertionError ( error_msg ) return hash_from_code ( '\n' . join ( to_hash ) )
return an md5 hash that uniquely identifies a module .