<s> from passpie . importers import BaseImporter <EOL> from . csv_importer import unicode_csv_reader <EOL> class KeepassImporter ( BaseImporter ) : <EOL> def match ( self , filepath ) : <EOL> expected_headers = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> with open ( filepath ) as csv_file : <EOL> reader = unicode_csv_reader ( csv_file ) <EOL> try : <EOL> headers = next ( reader ) <EOL> except StopIteration : <EOL> raise ValueError ( '<STR_LIT>' % filepath ) <EOL> return headers == expected_headers <EOL> return False <EOL> def handle ( self , filepath , ** kwargs ) : <EOL> credentials = [ ] <EOL> with open ( filepath ) as csv_file : <EOL> reader = unicode_csv_reader ( csv_file ) <EOL> try : <EOL> next ( reader ) <EOL> except StopIteration : <EOL> raise ValueError ( '<STR_LIT>' % filepath ) <EOL> for row in reader : <EOL> credential = { <EOL> '<STR_LIT:name>' : row [ <NUM_LIT:4> ] , <EOL> '<STR_LIT>' : row [ <NUM_LIT:2> ] , <EOL> '<STR_LIT:password>' : row [ <NUM_LIT:3> ] , <EOL> '<STR_LIT>' : row [ <NUM_LIT:5> ] , <EOL> } <EOL> credentials . append ( credential ) <EOL> return credentials </s>
