Convert a dRuby reference to the local object it refers to.
545616
def to_obj(ref)
      return front if ref.nil?
      return front[ref.to_s] if DRbURIOption === ref
      @idconv.to_obj(ref)
    end
548061
public function convert_references_to_local() {
        $fs = get_file_storage();
        $files = $fs->get_external_files($this->id);
        foreach ($files as $storedfile) {
            $fs->import_external_file($storedfile);
        }
    }
38096
def _get_reference(self):
        """"""
        sha, target_ref_path = self._get_ref_info(self.repo, self.path)
        if target_ref_path is None:
            raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
        return self.from_path(self.repo, target_ref_path)
1280196
def clone(src, **kwargs):
    """"""
    obj = object.__new__(type(src))
    obj.__dict__.update(src.__dict__)
    obj.__dict__.update(kwargs)
    return obj
955634
def to_native(self, obj, name, value):  # pylint:disable=unused-argument
		""""""
		
		from marrow.mongo import Document
		from marrow.mongo.trait import Derived
		
		kind = self._kind(obj.__class__)
		
		if isinstance(value, Document):
			if __debug__ and kind and issubclass(kind, Document) and not isinstance(value, kind):
				raise ValueError("Not an instance of " + kind.__name__ + " or a sub-class: " + repr(value))
			
			return value
		
		if isinstance(kind, Field):
			return kind.transformer.native(value, (kind, obj))
		
		return (kind or Derived).from_mongo(value)
1245387
def relateObjectLocs(obj, entities, selectF):
    """"""
    #if obj in entities: return 0 # is already one of the entities
    try:                    obj = obj.loc # get object's location, if it has one
    except AttributeError:  pass # assume obj is already a MapPoint
    try:                    func = obj.direct2dDistance # assume obj is a MapPoint
    except AttributeError:  raise ValueError("object %s (%s) does not possess and is not a %s"%(obj, type(obj), MapPoint))
    try:                    return selectF([(func(b.loc), b) for b in entities])
    except AttributeError:  return selectF([(func(b)    , b) for b in entities])
160462
def dump_type(self, obj):
        """"""
        if not isinstance(obj.relation_type, RelationType):
            return resolve_relation_type_config(obj.relation_type).name
        else:
            return obj.relation_type.name
795943
def to_native(self, obj, name, value):  # pylint:disable=unused-argument
		""""""
		
		if self.mapping:
			for original, new in self.mapping.items():
				value = value.replace(original, new)
		
		return load(value, self.namespace)
169301
def get_local_references(tb, max_string_length=1000):
    
    if 'self' in tb.tb_frame.f_locals:
        _locals = [('self', repr(tb.tb_frame.f_locals['self']))]
    else:
        _locals = []
    for k, v in tb.tb_frame.f_locals.iteritems():
        if k == 'self':
            continue
        try:
            vstr = format_reference(v, max_string_length=max_string_length)
            _locals.append((k, vstr))
        except TypeError:
            pass
    return _locals
616344
def extract(obj, pointer, bypass_ref=False):
    

    return Pointer(pointer).extract(obj, bypass_ref)
241131
function mapLocalReference (node) {
    if ((node === undefined) || (node === null)) return undefined;
    var ref = _getFirstChildNS(node, 'Ref');
    if ((ref === undefined) || (ref === null)) return undefined;
    return getAttrValue(ref, 'id');
  }
374442
def to_gremlin(self):
        """"""
        self.validate()

        local_object_name = self.get_local_object_gremlin_name()

        if self.field_name == '@this':
            return local_object_name

        if '@' in self.field_name:
            return u'{}[\'{}\']'.format(local_object_name, self.field_name)
        else:
            return u'{}.{}'.format(local_object_name, self.field_name)
89627
def filter_locals(locals_dict, drop=None, include=None):
    
    drop = drop or []
    drop.extend([
        'self',
        '__class__',  # py3
    ])

    include = include or locals_dict.keys()

    relevant_keys = [key for key in include if key not in drop]

    locals_dict = {k: v for k, v in locals_dict.items() if k in relevant_keys}

    return locals_dict
1095163
def to_foreign(self, obj, name, value):  # pylint:disable=unused-argument
		""""""
		
		if self.cache:
			return self._populate_cache(value)
		
		identifier = value
		
		# First, we handle the typcial Document object case.
		if isinstance(value, Document):
			identifier = value.__data__.get('_id', None)
			if identifier is None:
				raise ValueError("Can only store a reference to a saved Document instance with an `_id` stored.")
		
		elif isinstance(value, (str, unicode)) and len(value) == 24:
			try:
				identifier = OID(value)
			except InvalidId:
				pass
		
		kind = self._kind(obj.__class__)
		
		if self.concrete:
			if isinstance(value, Document) and value.__collection__:
				return DBRef(value.__collection__, identifier)
			
			if getattr(kind, '__collection__', None):
				return DBRef(kind.__collection__, identifier)
			
			raise ValueError("Could not infer collection name.")
		
		return identifier
764828
def to_foreign(self, obj, name, value):
		""""""
		
		if isinstance(value, Iterable) and not isinstance(value, Mapping):
			return self.List(super(Array, self).to_foreign(obj, name, i) for i in value)
		
		return super(Array, self).to_foreign(obj, name, value)
168012
def to_arrayref(u):
    
    if u.__class__ is node.funcall:
        try:
            if u.func_expr.props in "UR": # upd,ref
                u.__class__ = node.arrayref
        except:
            pass
235227
def dict_to_object(d):
    """"""
    top = type('CreateSendModel', (object,), d)
    seqs = tuple, list, set, frozenset
    for i, j in d.items():
        if isinstance(j, dict):
            setattr(top, i, dict_to_object(j))
        elif isinstance(j, seqs):
            setattr(top, i, type(j)(dict_to_object(sj) if isinstance(sj, dict) else sj for sj in j))
        else:
            setattr(top, i, j)
    return top