Helper context manager for :meth:`buffer` which saves the whole state.

        This is broken out in a separate method for readability and tested
        indirectly by testing :meth:`buffer`.
13173
def _save_state(self):
        
        ns_prefixes_floating_in = copy.copy(self._ns_prefixes_floating_in)
        ns_prefixes_floating_out = copy.copy(self._ns_prefixes_floating_out)
        ns_decls_floating_in = copy.copy(self._ns_decls_floating_in)
        curr_ns_map = copy.copy(self._curr_ns_map)
        ns_map_stack = copy.copy(self._ns_map_stack)
        pending_start_element = self._pending_start_element
        ns_counter = self._ns_counter
        # XXX: I have been unable to find a test justifying copying this :/
        # for completeness, I’m still doing it
        ns_auto_prefixes_floating_in = \
            copy.copy(self._ns_auto_prefixes_floating_in)
        try:
            yield
        except:  # NOQA: E722
            self._ns_prefixes_floating_in = ns_prefixes_floating_in
            self._ns_prefixes_floating_out = ns_prefixes_floating_out
            self._ns_decls_floating_in = ns_decls_floating_in
            self._pending_start_element = pending_start_element
            self._curr_ns_map = curr_ns_map
            self._ns_map_stack = ns_map_stack
            self._ns_counter = ns_counter
            self._ns_auto_prefixes_floating_in = ns_auto_prefixes_floating_in
            raise
103960
def save(self, model_fname='model.pkl'):
        
        with open(model_fname, 'wb') as fh:
            pickle.dump(self.stmts, fh, protocol=4)
666017
def with_haml_buffer(buffer)
      @haml_buffer, old_buffer = buffer, @haml_buffer
      old_buffer.active, old_was_active = false, old_buffer.active? if old_buffer
      @haml_buffer.active, was_active = true, @haml_buffer.active?
      yield
    ensure
      @haml_buffer.active = was_active
      old_buffer.active = old_was_active if old_buffer
      @haml_buffer = old_buffer
    end
351893
def _flush(self, buffer):
        
        if not self.state.should_try():
            logger.error("dropping flushed data due to transport failure back-off")
        else:
            fileobj = buffer.fileobj  # get a reference to the fileobj before closing the gzip file
            buffer.close()

            # StringIO on Python 2 does not have getbuffer, so we need to fall back to getvalue
            data = fileobj.getbuffer() if hasattr(fileobj, "getbuffer") else fileobj.getvalue()
            try:
                self.send(data)
                self.handle_transport_success()
            except Exception as e:
                self.handle_transport_fail(e)
945424
def _save_state(self, state_file, last_pk):
        """"""
        fp = open(state_file, 'w+')
        try:
            fp.write(str(last_pk))
        finally:
            fp.close()
1215452
def save
      buffer = render

      File.open(path, 'wb') { |f| f.write(buffer.string) }
    end
873076
private Object getSavedState(FacesContext facesContext)
    {
        Object encodedState = 
            facesContext.getExternalContext().getRequestParameterMap().get(STANDARD_STATE_SAVING_PARAM);
        if(encodedState==null || (((String) encodedState).length() == 0))
        {
            return null;
        }

        Object savedStateObject = _stateTokenProcessor.decode(facesContext, (String)encodedState);
        
        return savedStateObject;
    }
488174
public Object saveState(FacesContext context)
    {
        if (!initialStateMarked())
        {
            Object values[] = new Object[2];
            values[0] = _maximum;
            values[1] = _minimum;
            return values;
        }
        return null;
    }
1044127
def save(self, *args):
        
        with open(self.file_root + '.pkl', "wb") as f:
            pickle.dump(args, f, protocol=pickle.HIGHEST_PROTOCOL)
518670
def store_transition(self, frame, action, reward, done, extra_info=None):
        
        self.current_idx = (self.current_idx + 1) % self.buffer_capacity

        self.state_buffer[self.current_idx] = frame
        self.action_buffer[self.current_idx] = action
        self.reward_buffer[self.current_idx] = reward
        self.dones_buffer[self.current_idx] = done

        for name in self.extra_data:
            self.extra_data[name][self.current_idx] = extra_info[name]

        if self.current_size < self.buffer_capacity:
            self.current_size += 1

        return self.current_idx
1321971
def paste_buffer(pymux, variables):
    
    pane = pymux.arrangement.get_active_pane()
    pane.process.write_input(get_app().clipboard.get_data().text, paste=True)
198328
def save_raw(self):
        
        length = ctypes.c_ulong()
        cptr = ctypes.POINTER(ctypes.c_char)()
        _check_call(_LIB.XGBoosterGetModelRaw(self.handle,
                                              ctypes.byref(length),
                                              ctypes.byref(cptr)))
        return ctypes2buffer(cptr, length.value)
619845
def cache_context(self, context):
        '''
        
        '''
        if not os.path.isdir(os.path.dirname(self.cache_path)):
            os.mkdir(os.path.dirname(self.cache_path))
        with salt.utils.files.fopen(self.cache_path, 'w+b') as cache:
            self.serial.dump(context, cache)
980535
def _cleanup_buffer(self):
        '''
        
        '''
        if not self._buffer:
            return
        while True:
            time.sleep(60)
            log.debug('Cleaning up buffer')
            items = self._buffer.items()
            # The ``items`` function should also cleanup the buffer
            log.debug('Collected items')
            log.debug(list(items))
840215
def put_buffer(filename, content, conn=None):
    
    obj_dict = {PRIMARY_FIELD: filename,
                CONTENT_FIELD: content,
                TIMESTAMP_FIELD: time()}
    return put(obj_dict, conn=conn)
25920
def shot_save(self, ):
        
        if not self.cur_shot:
            return

        desc = self.shot_desc_pte.toPlainText()
        start = self.shot_start_sb.value()
        end = self.shot_end_sb.value()
        handle = self.shot_handle_sb.value()
        self.cur_shot.description = desc
        self.cur_shot.startframe = start
        self.cur_shot.endframe = end
        self.cur_shot.handlesize = handle
        self.cur_shot.save()
1327414
def _save_state(self, resp, context):
        

        cookie = state_to_cookie(context.state, self.config["COOKIE_STATE_NAME"], "/",
                                 self.config["STATE_ENCRYPTION_KEY"])
        resp.headers.append(tuple(cookie.output().split(": ", 1)))