#NEWLINE# def load( self , filename ) : #NEWLINE# #INDENT# '\n        Load and index keys from OpenSSH known_hosts file. In order to\n        preserve lines, the text content is stored in a list (_lines),\n        and indexes are used to keep line number(s) per host, as well as\n        index lists for hashed hosts and wildcard matches, which would\n        both need to be sequentially scanned if the host is not found\n        in the primary index lookup.\n\n        If this method is called multiple times, the host keys are appended,\n        not cleared.  So multiple calls to `load` will produce a concatenation\n        of the loaded files, in order.\n        ' #NEWLINE# offset = len ( self . _lines ) #NEWLINE# with open ( filename , 'r' ) as f : #NEWLINE# #INDENT# for ( lineno , line ) in enumerate ( f ) : #NEWLINE# #INDENT# self . _lines . append ( line . rstrip ( '\n' ) ) #NEWLINE# try : #NEWLINE# #INDENT# e = HostKeyEntry . from_line ( line , lineno ) #NEWLINE# if ( e is not None ) : #NEWLINE# #INDENT# for h in e . hostnames : #NEWLINE# #INDENT# if h . startswith ( '|' ) : #NEWLINE# #INDENT# self . _hashed_hosts . append ( ( h , ( offset + lineno ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if h . startswith ( '!' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( '*' in h ) or ( '?' in h ) ) : #NEWLINE# #INDENT# self . _wildcards . append ( ( h , ( offset + lineno ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _index [ h ] . append ( ( offset + lineno ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except ( UnreadableKey , TypeError ) as e : #NEWLINE# #INDENT# logging . getLogger ( 'radssh.keys' ) . error ( ( 'Skipping unloadable key line (%s:%d): %s' % ( filename , ( lineno + 1 ) , line ) ) ) #NEWLINE# pass