Unserialize saved note data.

        Args:
            state (dict): Serialized state to load.
174865
def restore(self, state):
        
        self._clear()
        self._parseUserInfo({'labels': state['labels']})
        self._parseNodes(state['nodes'])
        self._keep_version = state['keep_version']
1365134
def save(self, cachedir=None, cfgstr=None, verbose=VERBOSE, quiet=QUIET,
             ignore_keys=None):
        
        fpath = self.get_fpath(cachedir, cfgstr=cfgstr)
        if verbose:
            print('[Cachable] cache save: %r' % (basename(fpath),))

        if hasattr(self, '__getstate__'):
            statedict = self.__getstate__()
        else:
            statedict = self.__dict__

        if ignore_keys is None:
            save_dict = statedict
        else:
            save_dict = {key: val
                         for (key, val) in six.iteritems(statedict)
                         if key not in ignore_keys}

        util_io.save_data(fpath, save_dict)
        return fpath
747660
def state(cls, obj, state=None):
        
        if state is None:
            ids = cls.capture_ids(obj)
            original_custom_keys = set(Store.custom_options().keys())
            return (ids, original_custom_keys)
        else:
            (ids, original_custom_keys) = state
            current_custom_keys = set(Store.custom_options().keys())
            for key in current_custom_keys.difference(original_custom_keys):
                del Store.custom_options()[key]
                cls.restore_ids(obj, ids)
935076
def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, max_age=None):
    
    # TimestampSigner.unsign() returns str but base64 and zlib compression
    # operate on bytes.
    base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))
    decompress = False
    if base64d[:1] == b'.':
        # It's compressed; uncompress it first
        base64d = base64d[1:]
        decompress = True
    data = b64_decode(base64d)
    if decompress:
        data = zlib.decompress(data)
    return serializer().loads(data)
1066783
def save_state(self):
        
        if not self.filename:
            self.logger.error('Filename not specified. Could not save state')
            return
        self.logger.debug('Saving system state to %s', self.filename)
        for i in reversed(range(self.num_state_backups)):
            fname = self.filename if i == 0 else '%s.%d' % (self.filename, i)
            new_fname = '%s.%d' % (self.filename, i+1)
            try:
                os.rename(fname, new_fname)
            except FileNotFoundError:
                pass

        with open(self.filename, 'wb') as file, self.worker_thread.queue.mutex:
            obj_list = list(self.objects)
            config = {obj.name: obj.status for obj in obj_list
                      if getattr(obj, 'user_editable', False)}
            data = obj_list, config
            pickle.dump((STATEFILE_VERSION, data), file, pickle.HIGHEST_PROTOCOL)
423143
def decode(self, encoding=None):
        '''  '''
        copy = FormsDict()
        enc = copy.input_encoding = encoding or self.input_encoding
        copy.recode_unicode = False
        for key, value in self.allitems():
            copy.append(self._fix(key, enc), self._fix(value, enc))
        return copy
167994
def load(self, data: dict):
        
        for i, label in enumerate(self.keys):
            key = label.cget('text')
            if key in data.keys():
                entry_was_enabled = True if \
                    self.values[i].cget('state') == 'normal' else False
                if not entry_was_enabled:
                    self.values[i].config(state='normal')

                self.values[i].delete(0, tk.END)
                self.values[i].insert(0, str(data[key]))

                if not entry_was_enabled:
                    self.values[i].config(state='disabled')
527560
public void restore(String state) {
        JsonObject json = JsonObject.readFrom(state);
        String accessToken = json.get("accessToken").asString();
        String refreshToken = json.get("refreshToken").asString();
        long lastRefresh = json.get("lastRefresh").asLong();
        long expires = json.get("expires").asLong();
        String userAgent = json.get("userAgent").asString();
        String tokenURL = json.get("tokenURL").asString();
        String baseURL = json.get("baseURL").asString();
        String baseUploadURL = json.get("baseUploadURL").asString();
        boolean autoRefresh = json.get("autoRefresh").asBoolean();
        int maxRequestAttempts = json.get("maxRequestAttempts").asInt();

        this.accessToken = accessToken;
        this.refreshToken = refreshToken;
        this.lastRefresh = lastRefresh;
        this.expires = expires;
        this.userAgent = userAgent;
        this.tokenURL = tokenURL;
        this.baseURL = baseURL;
        this.baseUploadURL = baseUploadURL;
        this.autoRefresh = autoRefresh;
        this.maxRequestAttempts = maxRequestAttempts;
    }
492417
def save_semantic_data_for_state(state, state_path_full):
    

    destination_script_file = os.path.join(state_path_full, SEMANTIC_DATA_FILE)

    try:
        storage_utils.write_dict_to_json(state.semantic_data, destination_script_file)
    except IOError:
        logger.exception("Storing of semantic data for state {0} failed! Destination path: {1}".
                         format(state.get_path(), destination_script_file))
        raise
229129
def unserialize(cls, string, secret_key):
        
        if isinstance(string, text_type):
            string = string.encode('utf-8', 'replace')
        if isinstance(secret_key, text_type):
            secret_key = secret_key.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split(b'?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split(b'&'):
                mac.update(b'|' + item)
                if not b'=' in item:
                    items = None
                    break
                key, value = item.split(b'=', 1)
                # try to make the key a string
                key = url_unquote_plus(key.decode('ascii'))
                try:
                    key = to_native(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64.b64decode(base64_hash)
            except TypeError:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in iteritems(items):
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
62521
def _load_state(self, context):
        
        try:
            state = cookie_to_state(
                    context.cookie,
                    self.config["COOKIE_STATE_NAME"],
                    self.config["STATE_ENCRYPTION_KEY"])
        except SATOSAStateError as e:
            msg_tmpl = 'Failed to decrypt state {state} with {error}'
            msg = msg_tmpl.format(state=context.cookie, error=str(e))
            satosa_logging(logger, logging.WARNING, msg, None)
            state = State()
        finally:
            context.state = state
378021
def to_dict(obj):
        
        # Have text description of state in Json object (for readability)
        json_obj = {'type' : repr(obj)}
        # Add state-specific elementsTYPE_MODEL_RUN
        if obj.is_failed:
            json_obj['errors'] = obj.errors
        elif obj.is_success:
            json_obj['modelOutput'] = obj.model_output
        return json_obj
956002
def serialize(self):
        
        return {"hstart": self.hstart, "mstart": self.mstart,
                "hend": self.hend, "mend": self.mend,
                "is_valid": self.is_valid}
1202760
def save_state(internal_request, state):
        
        state_data = {"hash_type": internal_request.user_id_hash_type}
        state[UserIdHasher.STATE_KEY] = state_data
863461
def init_state_from_ledger(self, state: State, ledger: Ledger, reqHandler):
        
        if state.isEmpty:
            logger.info('{} found state to be empty, recreating from '
                        'ledger'.format(self))
            for seq_no, txn in ledger.getAllTxn():
                txn = self.update_txn_with_extra_data(txn)
                reqHandler.updateState([txn, ], isCommitted=True)
                state.commit(rootHash=state.headHash)
815214
function toStorableMessageState(messageState, message, context) {
  if (!messageState) {
    context.warn(`Skipping save of state for message, since it has no state - message (${JSON.stringify(message)})`);
    return undefined;
  }

  // Convert the message's state into a safely storable object to get a clean, simplified version of its state
  const state = dynamoDBUtils.toStorableObject(messageState);

  // If state has no message identifier then have no way to identify the message ... so attach a safely storable copy of
  // its original message, user record or record (if any) (i.e. without its legacy state, if any, for later matching)!
  if (!hasMessageIdentifier(messageState)) {
    message = message || messageState.message;

    if (message) {
      // Make a storable copy of the message & attach it to the storable state
      state.message = dynamoDBUtils.toStorableObject(message);
      // Remove the message copy's LEGACY state (if any) to get back to the original message
      tracking.deleteLegacyState(message, context);
    }
    else if (messageState.userRecord) {
      // If has no message, then attach a copy of its user record
      // Make a storable copy of the unusable user record & attach it to the storable state
      state.userRecord = dynamoDBUtils.toStorableObject(messageState.userRecord);
      // Remove the unusable user record copy's LEGACY state (if any) to get back to the original user record
      tracking.deleteLegacyState(state.userRecord, context);
    }
    else if (messageState.record) {
      // If has no message AND no user record, then attach a copy of its record
      // Make a storable copy of the unusable record & attach it to the storable state
      state.record = dynamoDBUtils.toStorableObject(messageState.record);
      // remove the unusable record copy's LEGACY state (if any) to get back to the original record
      tracking.deleteLegacyState(state.record, context);
    }
  }
  return state;
}
513199
def Deserialize(self, reader):
        
        super(AccountState, self).Deserialize(reader)
        self.ScriptHash = reader.ReadUInt160()
        self.IsFrozen = reader.ReadBool()
        num_votes = reader.ReadVarInt()
        for i in range(0, num_votes):
            self.Votes.append(reader.ReadBytes(33))

        num_balances = reader.ReadVarInt()
        self.Balances = {}
        for i in range(0, num_balances):
            assetid = reader.ReadUInt256()
            amount = reader.ReadFixed8()
            self.Balances[assetid] = amount