<s> import csv <EOL> import hashlib <EOL> import logging <EOL> import random <EOL> def load_csv ( csvfile ) : <EOL> f = csv . DictReader ( open ( csvfile , "<STR_LIT:rb>" ) , dialect = '<STR_LIT>' ) <EOL> return f <EOL> def make_key ( fields , data ) : <EOL> key_string = '<STR_LIT>' % ( data [ fields [ <NUM_LIT:0> ] ] , data [ fields [ <NUM_LIT:1> ] ] , data [ fields [ <NUM_LIT:2> ] ] , data [ fields [ <NUM_LIT:3> ] ] ) <EOL> h = hashlib . sha1 ( ) <EOL> h . update ( key_string ) <EOL> return h . hexdigest ( ) <EOL> def get_keys ( csvfile , size ) : <EOL> logging . info ( '<STR_LIT>' ) <EOL> f = load_csv ( csvfile ) <EOL> key_list = [ ] <EOL> for row in f : <EOL> key_list . append ( make_key ( f . fieldnames , row ) ) <EOL> logging . info ( '<STR_LIT>' ) <EOL> keys = [ ] <EOL> for x in xrange ( <NUM_LIT:0> , size ) : <EOL> keys . append ( key_list . pop ( random . randint ( <NUM_LIT:0> , len ( key_list ) - <NUM_LIT:1> ) ) ) <EOL> return keys </s>
