server/utils.py
changeset 9467 ad66d7b3fd48
parent 9167 c05652b108ce
child 9468 39b7a91a3f4c
equal deleted inserted replaced
9466:c3a5f4507f12 9467:ad66d7b3fd48
    69             return salt
    69             return salt
    70     except ValueError: # e.g. couldn't identify hash
    70     except ValueError: # e.g. couldn't identify hash
    71         pass
    71         pass
    72     # wrong password
    72     # wrong password
    73     return ''
    73     return ''
    74 
       
    75 def cartesian_product(seqin):
       
    76     """returns a generator which returns the cartesian product of `seqin`
       
    77 
       
    78     for more details, see :
       
    79     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302478
       
    80     """
       
    81     def rloop(seqin, comb):
       
    82         """recursive looping function"""
       
    83         if seqin:                   # any more sequences to process?
       
    84             for item in seqin[0]:
       
    85                 newcomb = comb + [item] # add next item to current combination
       
    86                 # call rloop w/ remaining seqs, newcomb
       
    87                 for item in rloop(seqin[1:], newcomb):
       
    88                     yield item          # seqs and newcomb
       
    89         else:                           # processing last sequence
       
    90             yield comb                  # comb finished, add to list
       
    91     return rloop(seqin, [])
       
    92 
    74 
    93 
    75 
    94 def eschema_eid(session, eschema):
    76 def eschema_eid(session, eschema):
    95     """get eid of the CWEType entity for the given yams type. You should use
    77     """get eid of the CWEType entity for the given yams type. You should use
    96     this because when schema has been loaded from the file-system, not from the
    78     this because when schema has been loaded from the file-system, not from the