Projet

Général

Profil

0002-utils-add-helper-function-to-lowercase-the-keys-of-a.patch

Benjamin Dauvergne, 23 mars 2015 16:28

Télécharger (972 octets)

Voir les différences:

Subject: [PATCH 2/4] utils: add helper function to lowercase the keys of a
 dictionnary

 src/authentic2/utils.py | 4 ++++
 1 file changed, 4 insertions(+)
src/authentic2/utils.py
444 444
def batch(iterable, size):
445 445
    '''Batch an iterable as an iterable of iterables of at most size element
446 446
       long.
447 447
    '''
448 448
    sourceiter = iter(iterable)
449 449
    while True:
450 450
        batchiter = islice(sourceiter, size)
451 451
        yield chain([batchiter.next()], batchiter)
452

  
453
def lower_keys(d):
454
    '''Convert all keys in dictionary d to lowercase'''
455
    return dict((key.lower(), value) for key, value in d.iteritems())
452
-