Ignore:
Timestamp:
12/03/12 15:43:46 (8 years ago)
Author:
mnagni
Message:

Implementation of tickets #22390

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/ascore/utils.py

    r8089 r8147  
    1111            return False 
    1212    return False 
     13 
     14def collectionProofHash(tupleToHash): 
     15    try: 
     16        return hash(tuple(_convertCollectionToList(tupleToHash))) 
     17    except Exception as e: 
     18        print e 
     19 
     20def _convertCollectionToList(tupleToHash, processedItems = []):  
     21    toHash = [] 
     22    for item in tupleToHash: 
     23        if item in processedItems: 
     24            continue 
     25        processedItems.append(item) 
     26        if type(item) == tuple or type(item) == list: 
     27            for innerItem in item: 
     28                toHash.extend(collectionProofHash(innerItem, processedItems)) 
     29        elif type(item) == dict: 
     30            for innerItem in item.keys(): 
     31                toHash.extend(collectionProofHash(innerItem, processedItems)) 
     32            for innerItem in item.values(): 
     33                toHash.extend(collectionProofHash(innerItem, processedItems)) 
     34        else: 
     35            toHash.append(item) 
     36    return toHash 
Note: See TracChangeset for help on using the changeset viewer.