Copy the state of another `Grab` instance.

        Use case: create backup of current state to the cloned instance and
        then restore the state from it.
548573
def adopt(self, grab):
        

        self.load_config(grab.config)

        self.doc = grab.doc.copy(new_grab=self)

        for key in self.clonable_attributes:
            setattr(self, key, getattr(grab, key))
        self.cookies = deepcopy(grab.cookies)
122105
def copy
    copy = self.clone #Currently, we overwrite everything anyway, but we may add some clonable attributes later.
    #Make a deep copy of all objects.
    copy.instance_eval {@objects = {}}
    self.objects.each {|object| copy.add_object(object.copy)}
    #Make a deep copy of all environmental_factors.
    copy.clear_environmental_factors
    self.environmental_factors.each {|environmental_factor| copy.add_environmental_factor(environmental_factor)}
    copy
  end
1114502
def restore(self):
        
        if os.path.exists(self.backup_path):
            for file in glob.glob(self.backup_path + "/*"):
                shutil.copy(file, self.path)
524263
def copy(self):
		
		out = self._from_iterable(None)
		out._dict = self._dict.copy()
		out._size = self._size
		return out
400054
def copy_from_local(self, localsrc, dest, **kwargs):
        
        with io.open(localsrc, 'rb') as f:
            self.create(dest, f, **kwargs)
564082
def copy(self, target):
        
        shutil.copy(self.path, self._to_backend(target))
630388
def clone(self, **kwargs):
        

        # First, create exact copy of the current Task object
        attr_copy = self.__dict__.copy()
        if attr_copy.get('grab_config') is not None:
            del attr_copy['url']
        if not attr_copy['priority_set_explicitly']:
            attr_copy['priority'] = None
        task = Task(**attr_copy)

        # Reset some task properties if they have not
        # been set explicitly in kwargs
        if 'network_try_count' not in kwargs:
            task.network_try_count = 0
        if 'task_try_count' not in kwargs:
            task.task_try_count = self.task_try_count + 1
        if 'refresh_cache' not in kwargs:
            task.refresh_cache = False
        if 'disable_cache' not in kwargs:
            task.disable_cache = False

        if kwargs.get('url') is not None and kwargs.get('grab') is not None:
            raise SpiderMisuseError('Options url and grab could not be '
                                    'used together')

        if (kwargs.get('url') is not None and
                kwargs.get('grab_config') is not None):
            raise SpiderMisuseError('Options url and grab_config could not '
                                    'be used together')

        if (kwargs.get('grab') is not None and
                kwargs.get('grab_config') is not None):
            raise SpiderMisuseError('Options grab and grab_config could not '
                                    'be used together')

        if kwargs.get('grab'):
            task.setup_grab_config(kwargs['grab'].dump_config())
            del kwargs['grab']
        elif kwargs.get('grab_config'):
            task.setup_grab_config(kwargs['grab_config'])
            del kwargs['grab_config']
        elif kwargs.get('url'):
            task.url = kwargs['url']
            if task.grab_config:
                task.grab_config['url'] = kwargs['url']
            del kwargs['url']

        for key, value in kwargs.items():
            setattr(task, key, value)

        task.process_delay_option(None)

        return task
1264989
def copy(self):
        
        return self.__class__(options=self.__options,
                              attribute_options=self.__attribute_options)
771557
def copy(self):
        
        result = copy.deepcopy(self)
        result._cache.clear()
        return result
301980
def initialize_copy(original)
      instance_variables.each do |ivar|
        instance_variable_set(ivar, DataMapper::Ext.try_dup(instance_variable_get(ivar)))
      end

      self.persistence_state = persistence_state.class.new(self)
    end
809230
def initialize_copy(other)
      @steps = other.steps.map do |step|
        step.class.new(self, *step.args)
      end
      @content = other.content.dup
      @url_attributes = other.url_attributes.dup
    end
391122
def copy(self, request, **kwargs):
        # pylint: disable=unused-argument
        '''
        
        '''
        instance = self.copy_instance(self.get_object())
        serializer = self.get_serializer(instance, data=request.data, partial=True)
        serializer.is_valid()
        serializer.save()
        return Response(serializer.data, status.HTTP_201_CREATED).resp
622656
def copy(self):
        

        new_digest = Digest(self.digest_type)
        libcrypto.EVP_MD_CTX_copy(new_digest.ctx, self.ctx)
        return new_digest
1204992
def _copy_future_state(source, dest):
    
    assert source.done()
    if dest.cancelled():
        return
    assert not dest.done()
    if source.cancelled():
        dest.cancel()
    else:
        exception = source.exception()
        if exception is not None:
            dest.set_exception(exception)
        else:
            result = source.result()
            dest.set_result(result)
862804
function cloneState(state) {
  return {
    options: state.options,
    stack: state.stack.slice(),
    nodes: state.nodes.slice()
  };
}
1315808
def copy(self, selection, smart_selection_adaption=True):
        
        assert isinstance(selection, Selection)
        self.__create_core_and_model_object_copies(selection, smart_selection_adaption)
106933
def clone(self, new_object):
        
        return self.__class__(new_object, self.method, self.name)