Walks an object and marshals any psphere object into MORs.
496987
def _marshal(self, obj):
        """"""
        logger.debug("Checking if %s needs to be marshalled", obj)
        if isinstance(obj, ManagedObject):
            logger.debug("obj is a psphere object, converting to MOR")
            return obj._mo_ref

        if isinstance(obj, list):
            logger.debug("obj is a list, recursing it")
            new_list = []
            for item in obj:
                new_list.append(self._marshal(item))
            return new_list
                
        if not isinstance(obj, suds.sudsobject.Object):
            logger.debug("%s is not a sudsobject subclass, skipping", obj)
            return obj

        if hasattr(obj, '__iter__'):
            logger.debug("obj is iterable, recursing it")
            for (name, value) in obj:
                setattr(obj, name, self._marshal(value))
            return obj
            
        # The obj has nothing that we want to marshal or traverse, return it
        logger.debug("obj doesn't need to be marshalled")
        return obj
188001
def build(obj: Any, *applicators: Callable[..., Any]) -> Any:
    
    if isinstance(obj, BaseChain):
        return pipe(obj, copy(), *applicators)
    else:
        return pipe(obj, *applicators)
962181
function(context, descriptor, args, stack) {
		var obj = stack.shift();
		if (obj.val)
			secondPass(obj.rest, context, descriptor, obj.stack);
	}
987408
function(obj, path, value) {
  const parts = path.split('.')

  /* traverse existing path to nearest object */
  while (parts.length > 1 && typeof obj[parts[0]] === 'object') {
    obj = obj[parts.shift()]
  }

  /* set value */
  obj[parts[0]] = partsToValue(parts.slice(1), value)
}
555723
def map(self, options=None):
        """"""
        for path, data in self.paths.items():
            for obj in self.create_class(data, options=options):
                self.add_object(obj)
1064072
function walk (router, transform) {
  assert.equal(typeof router, 'function', 'wayfarer.walk: router should be an function')
  assert.equal(typeof transform, 'function', 'wayfarer.walk: transform should be a function')

  var trie = router._trie
  assert.equal(typeof trie, 'object', 'wayfarer.walk: trie should be an object')

  // (str, obj) -> null
  ;(function walk (route, trie) {
    if (trie.cb) {
      trie.cb = transform(route, trie.cb)
    }

    if (trie.nodes) {
      var nodes = trie.nodes
      Object.keys(nodes).forEach(function (key) {
        var node = nodes[key]
        var newRoute = (key === '$$')
          ? route + '/:' + trie.name
          : route + '/' + key
        walk(newRoute, node)
      })
    }
  })('', trie.trie)
}
602804
def incver(o, prop_names):
    """"""
    from ambry.identity import ObjectNumber

    d = {}

    for p in o.__mapper__.attrs:
        v = getattr(o, p.key)
        if v is None:
            d[p.key] = None
        elif p.key in prop_names:
            d[p.key] = str(ObjectNumber.increment(v))
        else:
            if not hasattr(v, '__mapper__'): # Only copy values, never objects
                d[p.key] = v

    return o.__class__(**d)
1217089
def _triplify_object(self, data, parent):
        
        subject = self.get_subject(data)
        if self.path:
            yield (subject, TYPE_SCHEMA, self.path, TYPE_SCHEMA)

        if parent is not None:
            yield (parent, self.predicate, subject, TYPE_LINK)
            if self.reverse is not None:
                yield (subject, self.reverse, parent, TYPE_LINK)

        for prop in self.properties:
            for res in prop.triplify(data.get(prop.name), subject):
                yield res
890642
def proj4_to_wkt(projection):
    """"""

    srs = osgeo.osr.SpatialReference()
    srs.ImportFromProj4(projection.srs)

    return srs.ExportToWkt()
1345444
def yamlmod(obj, *paths):
    '''
    
    '''
    oldobj = yamlload(*paths)
    if obj is not None:
        if oldobj:
            yamlsave({**oldobj, **obj}, *paths)
        else:
            yamlsave(obj, *paths)
7053
function through(transform, flush, objectMode) {
  const stream = new TransformStream({objectMode})
  stream._transform = transform || pass
  if (flush) stream._flush = flush
  return stream
}
1344424
function through(transform) {
  var th = new Transform({objectMode: true})

  th._transform = transform

  return th
}
625451
function (obj, filter) {
    var result = {};

    var walk = function (obj, filter, result, path, originObj) {
        var elem
            , arrResult;
        if (!originObj) {
            var originObj = obj;
        }
        if (!path) {
            path = '';
        }
        if (_.isObject(obj) && !_.isRegExp(obj) && !_.isFunction(obj)) {

            if (_.isEmpty(obj)) {
                result[path] = {}
            }
            else {

                for (var value in obj) {
                    if (_.isObject(obj[value]) && !_.isRegExp(obj[value]) && !_.isFunction(obj[value]) && value != 'public' && value != 'virtual' && value != 'allow' && value != 'deny' && value != 'convert') {
                        if (_.isArray(obj[value])) {

                            //Check if empty array
                            if (_.isEmpty((obj[value]))) {

                                if (_.isEmpty(path)) {
                                    elem = value;
                                }
                                else {
                                    elem = path + '.' + value + '';
                                }

                                if (!result[elem]) {
                                    result[elem] = [];
                                }
                            }
                            else {
                                //Check child elements of array
                                for (var thisArrayElem in obj[value]) {
                                    if (_.isEmpty(path)) {
                                        elem = value;
                                    }
                                    else {
                                        elem = path + '.' + value + ''; //This is somehow not correct
                                    }
                                    if (!result[elem]) {
                                        result[elem] = [];
                                    }
                                    arrResult = find(obj[value][thisArrayElem], filter);
                                    if (arrResult) {
                                        (result[elem]).push(arrResult);
                                    }

                                }
                            }
                        }
                        else {

                            var subPath = _.isEmpty(path) ? value : path + '.' + value + '';

                            if (!filter || value == filter) {
                                if (path == '') {
                                    try {
                                        result[value] = eval('originObj' + generateObjectPath(value) + '');
                                    } catch (e) {
                                    }
                                }
                                else {
                                    try {
                                        result[path] = eval('originObj' + generateObjectPath(path) + '');
                                    } catch (e) {
                                    }
                                }
                            }

                            result = walk(obj[value], filter, result, subPath, originObj);
                        }
                    }
                    else {

                        if (!filter || value == filter) {
                            if (path == '') {
                                try {
                                    result[value] = eval('originObj' + generateObjectPath(value) + '');
                                } catch (e) {
                                }
                            }
                            else {
                                try {
                                    result[path] = eval('originObj' + generateObjectPath(path) + '');
                                } catch (e) {
                                }
                            }
                        }

                    }
                }
            }
        }

        return result;
    };

    var resultArray = walk(obj, filter, result);
    return _.isEmpty(resultArray) ? false : resultArray;
}
1363154
function handleObject(object, schema, fullObject, path) {
    const resultObject = {};

    Object.keys(schema).forEach(propertyName => {
        if (propertyName.startsWith('$')) {
            return;
        }

        const propertyValue = object[propertyName];
        const propertyPath  = path.concat(propertyName);

        let propertySchema = schema[propertyName];
        if (propertySchema instanceof Function) {
            propertySchema = propertySchema(propertyValue, object, fullObject, propertyPath);
        }

        let newPropertyValue = propertyValue;

        if (propertySchema instanceof Object) {
            if (propertySchema.$default !== undefined && newPropertyValue === undefined) {
                newPropertyValue = propertySchema.$default;
            }

            const itemsSchema = propertySchema.$items || propertySchema[0];
            if (itemsSchema && Object.keys(itemsSchema).some(p => !p.startsWith('$')) && newPropertyValue instanceof Array) {
                const arraySchema = Array(newPropertyValue.length).fill(itemsSchema);
                const handledArrayLikeObject = handleObject(newPropertyValue, arraySchema, fullObject, propertyPath);
                newPropertyValue = Object.keys(handledArrayLikeObject).map(key => handledArrayLikeObject[key]);
            } else if (Object.keys(propertySchema).some(p => !p.startsWith('$')) && newPropertyValue instanceof Object) {
                newPropertyValue = handleObject(newPropertyValue, propertySchema, fullObject, propertyPath);
            }
        }

        resultObject[propertyName] = newPropertyValue;
    });

    return resultObject;
}
417171
function (obj, path) {
    if (Object.prototype.hasOwnProperty.call(obj, path)) {
      return obj[path];
    }

    var keys = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".");
    var copy = {};
    for (var attr in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, attr)) {
        copy[attr] = obj[attr];
      }
    }

    for (var i = 0, l = keys.length; i < l; i++) {
      if (Object.hasOwnProperty.call(copy, keys[i])) {
        copy = copy[keys[i]];
      } else {
        return;
      }
    }
    return copy;
  }
773076
protected void doPropagateAssertObject(InternalFactHandle factHandle,
                                           PropagationContext context,
                                           InternalWorkingMemory workingMemory,
                                           ObjectSink sink) {
        sink.assertObject( factHandle,
                           context,
                           workingMemory );
    }
1207120
def objects_to_root(objects: List) -> Root:
    

    def _to_tree(objs: Iterable) -> Dict:
        """
        Build a tree structure from a flat list of objects.

        :param objs: The raw iterable of S3 `ObjectSummary`s, as returned by a
                     bucket listing.
        :return: The listing as a nested dictionary where keys are directory
                 and file names. The values of directories will in turn be a
                 dict. The values of keys representing files will be the
                 `ObjectSummary` instance.
        """
        path_tree = {}
        for obj in objs:
            is_dir = obj.key.endswith('/')
            chunks = [chunk for chunk in obj.key.split('/') if chunk]
            chunk_count = len(chunks)
            tmp = path_tree
            for i, chunk in enumerate(chunks):
                is_last_chunk = i == chunk_count - 1

                if is_last_chunk and not is_dir:
                    tmp[chunk] = obj
                else:
                    # must be a directory
                    if chunk not in tmp:
                        # it doesn't exist - create it
                        tmp[chunk] = {}
                    tmp = tmp[chunk]
        return path_tree

    def _to_entity(key: str, value: Union[Dict, Any]) -> Entity:
        """
        Turn a nested dictionary representing an S3 bucket into the correct
        `Entity` object.

        :param key: The name of the entity.
        :param value: If the entity is a directory, the nested dict
                      representing its contents. Otherwise, the `ObjectSummary`
                      instance representing the file.
        :return: The entity representing the entity name and value pair.
        """
        if isinstance(value, dict):
            return Directory(
                key,
                {key_: _to_entity(key_, value_)
                 for key_, value_ in value.items()})

        return File(pathlib.PurePath(value.key).name, value.size,
                    value.e_tag.strip('"'))

    tree = _to_tree(objects)
    return Root({pathlib.PurePath(key).name: _to_entity(key, value)
                 for key, value in tree.items()})