def _extractCommon(string):
 elements = string.split(None, 2)
 if (len(elements) != 3):
  raise InvalidEntry()
 (hostnames, keyType, keyAndComment) = elements
 splitkey = keyAndComment.split(None, 1)
 if (len(splitkey) == 2):
  (keyString, comment) = splitkey
  comment = comment.rstrip('\n')
 else:
  keyString = splitkey[0]
  comment = None
 key = Key.fromString(keyString.decode('base64'))
 return (hostnames, keyType, key, comment)

def _extractCommon ( string ) : elements = string . split ( None , 2 ) if ( len ( elements ) != 3 ) : raise InvalidEntry ( ) ( hostnames , keyType , keyAndComment ) = elements splitkey = keyAndComment . split ( None , 1 ) if ( len ( splitkey ) == 2 ) : ( keyString , comment ) = splitkey comment = comment . rstrip ( '\n' ) else : keyString = splitkey [ 0 ] comment = None key = Key . fromString ( keyString . decode ( 'base64' ) ) return ( hostnames , keyType , key , comment )
extract common elements of base64 keys from an entry in a hosts file .