def from_string(cls, string):
        """
        Create a public blob from a ``-cert.pub``-style string.
        """
        fields = string.split(None, 2)
        if len(fields) < 2:
            msg = "Not enough fields for public blob: {}"
            raise ValueError(msg.format(fields))
        key_type = fields[0]
        key_blob = decodebytes(b(fields[1]))
        try:
            comment = fields[2].strip()
        except IndexError:
            comment = None
        # Verify that the blob message first (string) field matches the
        # key_type
        m = Message(key_blob)
        blob_type = m.get_text()
        if blob_type != key_type:
            deets = "key type={!r}, but blob type={!r}".format(
                key_type, blob_type
            )
            raise ValueError("Invalid PublicBlob contents: {}".format(deets))
        # All good? All good.
        return cls(type_=key_type, blob=key_blob, comment=comment)
def from_string ( cls , string ) : fields = string . split ( None , 2 ) if len ( fields ) < 2 : msg = "Not enough fields for public blob: {}" raise ValueError ( msg . format ( fields ) ) key_type = fields [ 0 ] key_blob = decodebytes ( b ( fields [ 1 ] ) ) try : comment = fields [ 2 ] . strip ( ) except IndexError : comment = None m = Message ( key_blob ) blob_type = m . get_text ( ) if blob_type != key_type : deets = "key type={!r}, but blob type={!r}" . format ( key_type , blob_type ) raise ValueError ( "Invalid PublicBlob contents: {}" . format ( deets ) ) return cls ( type_ = key_type , blob = key_blob , comment = comment )
Create a public blob from a ``-cert.pub``-style string.