Convert an object path reference to a reference.
352635
def path_to_reference(path):
    """"""

    # By default JSON decodes strings as unicode. The Python __import__ does
    # not like that choice. So we'll just cast all function paths to a string.
    # NOTE: that there is no corresponding unit test for the classmethod
    # version of this problem.  It only impacts importing modules.
    path = str(path)

    if '.' not in path:
        try:
            return globals()["__builtins__"][path]
        except KeyError:
            try:
                return getattr(globals()["__builtins__"], path)
            except AttributeError:
                pass

        try:
            return globals()[path]
        except KeyError:
            pass

        raise errors.BadObjectPathError(
            'Unable to find function "%s".' % (path,))

    module_path, function_name = path.rsplit('.', 1)

    try:
        module = __import__(name=module_path,
                            fromlist=[function_name])
    except ImportError:
        module_path, class_name = module_path.rsplit('.', 1)

        module = __import__(name=module_path, fromlist=[class_name])
        module = getattr(module, class_name)

    try:
        return getattr(module, function_name)
    except AttributeError:
        raise errors.BadObjectPathError(
            'Unable to find function "%s".' % (path,))
978507
function setFromPath(obj, path, value){
		var parts = path.split('.');
		
		for(var i = 0, l = parts.length; i < l; i++){
			if(i < (l - 1) && !obj.hasOwnProperty(parts[i]))
				obj[parts[i]] = {};
	
			if(i == l - 1)
				obj[parts[i]] = value;
			
			else
				obj = obj[parts[i]];
		}
		
		return obj;
	}
714268
function(path, obj) {
    if(path == '#') return obj;
    path = path.substr(1);
    var parts = path.split('/');
    parts.shift();

    // Locate object
    for(var i = 0; i < parts.length; i++) {
      obj = obj[parts[i]];
    }

    return obj;
  }
1207845
public static <T> T convert(TypeReference<T> reference, Object value) throws ConvertException{
		return convert(reference.getType(), value, null);
	}
421204
def _references(self, i, sequence=False):
        """"""

        value = ''
        c = next(i)
        if c == '\\':
            # \\
            if sequence and self.bslash_abort:
                raise PathNameException
            value = r'\\'
            if self.bslash_abort:
                if not self.in_list:
                    value = self.get_path_sep() + _ONE_OR_MORE
                    self.set_start_dir()
                else:
                    value = self._restrict_extended_slash() + value
        elif c == '/':
            # \/
            if sequence and self.pathname:
                raise PathNameException
            if self.pathname:
                value = r'\\'
                if self.in_list:
                    value = self._restrict_extended_slash() + value
                i.rewind(1)
            else:
                value = re.escape(c)
        else:
            # \a, \b, \c, etc.
            value = re.escape(c)
            if c == '.' and self.after_start and self.in_list:
                self.allow_special_dir = True
                self.reset_dir_track()

        return value
1153505
def from_path(cls, conn, path):
        """"""
        path = path.strip(SEP)
        full_path = os.path.join(conn.abs_root, path)
        return cls(conn, path, 0, os.path.getsize(full_path))
371509
def get_path(self, obj, default):
        """"""
        path = obj.get("path")
        if path is None:
            path = join(self._base, default)
        if not isabs(path):
            path = join(self._base, path)
        return path
420429
function fromPath(obj, path) {

	var pieces,
	    here,
	    len,
	    i;

	if (typeof path == 'string') {
		pieces = path.split('.');
	} else {
		pieces = path;
	}

	here = obj;

	// Go over every piece in the path
	for (i = 0; i < pieces.length; i++) {
		if (here != null) {
			if (here.hasOwnProperty(pieces[i])) {
				here = here[pieces[i]];
			} else {
				return null;
			}
		} else {
			break;
		}
	}

	return here;
}
1066155
private Object convertObjectToSingleValue(Object rawValue, ExtendedAttributeDefinition attrDef, EvaluationContext context, int index,
                                              boolean ignoreWarnings) throws ConfigEvaluatorException {
        if (rawValue instanceof String) {
            return convertStringToSingleValue((String) rawValue, attrDef, context, ignoreWarnings);
        } else if (rawValue instanceof ConfigElement.Reference) {
            ConfigElement.Reference reference = processReference((ConfigElement.Reference) rawValue, context, ignoreWarnings);
            if (attrDef != null && attrDef.getType() == MetaTypeFactory.PID_TYPE) {
                return evaluateReference(reference.getId(), attrDef, context);
            } else {
                return evaluateReference(reference, context);
            }
        } else if (rawValue instanceof ConfigElement) {
            return convertConfigElementToSingleValue((ConfigElement) rawValue, attrDef, context, index, ignoreWarnings);
        } else {
            throw new IllegalStateException("Unsupported type: " + rawValue.getClass());
        }
    }
528413
def _dereference(cls, documents, references):
        """"""

        # Dereference each reference
        for path, projection in references.items():

            # Check there is a $ref in the projection, else skip it
            if '$ref' not in projection:
                continue

            # Collect Ids of documents to dereference
            ids = set()
            for document in documents:
                value = cls._path_to_value(path, document)
                if not value:
                    continue

                if isinstance(value, list):
                    ids.update(value)

                elif isinstance(value, dict):
                    ids.update(value.values())

                else:
                    ids.add(value)

            # Find the referenced documents
            ref = projection.pop('$ref')
            frames = ref.many(
                {'_id': {'$in': list(ids)}},
                projection=projection
                )
            frames = {f._id: f for f in frames}

            # Add dereferenced frames to the document
            for document in documents:
                value = cls._path_to_value(path, document)
                if not value:
                    continue

                if isinstance(value, list):
                    # List of references
                    value = [frames[id] for id in value if id in frames]

                elif isinstance(value, dict):
                    # Dictionary of references
                    value = {key: frames.get(id) for key, id in value.items()}

                else:
                    value = frames.get(value, None)

                child_document = document
                keys = cls._path_to_keys(path)
                for key in keys[:-1]:
                    child_document = child_document[key]
                child_document[keys[-1]] = value
77440
function unsetPath(path, obj) {
  if(!isArray(path) || isEmpty(path)) {
    throw new TypeError(pathError)
  }

  if(!(isObject(obj) || isArray(obj))) {
    return obj
  }

  const key = path[0]

  if(!(isString(key) && !isEmpty(key) || isInteger(key) && key >= 0)) {
    throw new TypeError(pathError)
  }

  if(path.length === 1) {
    if(isArray(obj) && isInteger(key)) {
      return array.unset(key, obj)
    }

    if(isObject(obj) && isString(key)) {
      return object.unset(key, obj)
    }

    return obj
  }

  const next =
    obj[key]

  if(!(isObject(next) || isArray(next))) {
    return obj
  }

  if(isArray(obj)) {
    return array.set(key, unsetPath(path.slice(1), next), obj)
  }

  return object.set(key, unsetPath(path.slice(1), next), obj)
}
205596
def relative_path(reference_path, input_path):
        
        start_path = os.path.dirname(reference_path)
        try:
            relative_path = os.path.relpath(input_path, start_path)
        except ValueError:
            # LOGGER.info(e.message)
            relative_path = input_path
        return relative_path
845231
function createObjectSpread(path, file, objRef) {
    const props = path.get("properties");
    const last = props[props.length - 1];
    t.assertRestElement(last.node);
    const restElement = t.cloneNode(last.node);
    last.remove();

    const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path);
    const { keys, allLiteral } = extractNormalizedKeys(path);

    if (keys.length === 0) {
      return [
        impureComputedPropertyDeclarators,
        restElement.argument,
        t.callExpression(getExtendsHelper(file), [
          t.objectExpression([]),
          t.cloneNode(objRef),
        ]),
      ];
    }

    let keyExpression;
    if (!allLiteral) {
      // map to toPropertyKey to handle the possible non-string values
      keyExpression = t.callExpression(
        t.memberExpression(t.arrayExpression(keys), t.identifier("map")),
        [file.addHelper("toPropertyKey")],
      );
    } else {
      keyExpression = t.arrayExpression(keys);
    }

    return [
      impureComputedPropertyDeclarators,
      restElement.argument,
      t.callExpression(
        file.addHelper(`objectWithoutProperties${loose ? "Loose" : ""}`),
        [t.cloneNode(objRef), keyExpression],
      ),
    ];
  }
238660
def path(cls, ref):
        
        return osp.join(ref.repo.git_dir, "logs", to_native_path(ref.path))
45817
def get_path(self, reference=None):
        
        return list(reversed([item.get_name()
                              for item in self.get_trace(reference)
                              if item.get_name() is not None]))
207201
function getFromPath(obj, path){
		path = path.split('.');

		for(var i = 0, l = path.length; i < l; i++){
			if (hasOwnProperty.call(obj, path[i]))
				obj = obj[path[i]];
			
			else
				return undefined;
		}
		
		return obj;
	}
854106
private Object convertReference(Object fieldValue) {
    DocumentReference reference;
    if (fieldValue instanceof String) {
      reference = new DocumentReference(firestore, path.append((String) fieldValue));
    } else if (fieldValue instanceof DocumentReference) {
      reference = (DocumentReference) fieldValue;
    } else {
      throw new IllegalArgumentException(
          "The corresponding value for FieldPath.documentId() must be a String or a "
              + "DocumentReference.");
    }

    if (!this.path.isPrefixOf(reference.getResourcePath())) {
      throw new IllegalArgumentException(
          String.format(
              "'%s' is not part of the query result set and cannot be used as a query boundary.",
              reference.getPath()));
    }
    if (!reference.getParent().getResourcePath().equals(this.path)) {
      throw new IllegalArgumentException(
          String.format(
              "Only a direct child can be used as a query boundary. Found: '%s'",
              reference.getPath()));
    }

    return reference;
  }