

def _Initialize(self, kwargs):
    'Initializes envelope data from input.'
    self._mime_type = kwargs.get('mime_type', None)
    self._document = kwargs.get('document', None)
    if self._document:
        fields = self._protocol.Parse(self._document, self._mime_type)
        kwargs.update(fields)
    self._data = kwargs.get('data', None)
    self._data_type = kwargs.get('data_type', None)
    self._encoding = kwargs.get('encoding', 'base64url')
    self._alg = kwargs.get('alg', 'RSA-SHA256')
    self._sig = kwargs.get('sig', None)
    if (not self._data_type):
        raise EnvelopeError(self, 'Missing data_type')
    if (self._alg != 'RSA-SHA256'):
        raise EnvelopeError(self, ('Unknown alg %s; must be RSA-SHA256' % self._alg))
    if (self._encoding != 'base64url'):
        raise EnvelopeError(self, ('Unknown encoding %s; must be base64url' % self._encoding))
    raw_data = kwargs.get('raw_data_to_sign', None)
    if raw_data:
        assert self._data_type
        assert (not self._sig)
        assert (not self._data)
        assert ('signer_uri' in kwargs)
        assert ('signer_key' in kwargs)
        self._parsed_data = self._protocol.ParseData(raw_data, self._data_type)
        self._data = self._protocol.EncodeData(raw_data, self._encoding)
        self._signer_uri = kwargs['signer_uri']
        self._signer_key = kwargs['signer_key']
    elif self._sig:
        if (not self._data):
            raise EnvelopeError(self, 'No data to verify')
        raw_data = self._protocol.DecodeData(self._data, self._encoding)
    else:
        raise EnvelopeError(self, 'Insufficient data to initialize envelope.')
    self._parsed_data = self._protocol.ParseData(raw_data, self._data_type)
    self._init_timestamp = None

dataset/ETHPy150Open mimecuvalo/helloworld/packages/magicsig/__init__.py Envelope._Initialize/original