Handy Function To convert All ObjectIds to strings.
180467
function convertAllObjectIdsToString(form) {
  form._id = form._id ? form._id.toString() : form._id;
  form.pages = _.map(form.pages, function(page) {
    page._id = page._id ? page._id.toString() : page._id;

    page.fields = _.map(page.fields, function(field) {
      field._id = field._id ? field._id.toString() : field._id;
      return field;
    });

    return page;
  });
  return form;
}
1313013
function __deserializeObjectId(buffer, start, options) {
	let step = 1;
	let length = 12;
	let end = start + length;
	let dataView = new DataView(buffer);
	let dataArray = [];
	for (let i = start; i < end; i += step) {
		dataArray.push(dataView.getUint8(i));
	}
	let data = new ObjectId(Uint8Array.from(dataArray).buffer);
	return { anchor: end, value: data };
}
1371818
def ids(self, content_ids, object_ids):
        """"""
        result = []

        content_ids = self.split(content_ids, False)
        object_ids = self.split(object_ids)

        for cid in content_ids:
            result.append('{}:{}'.format(cid, ':'.join(object_ids)))

        return result
753472
def r_dts_collection(self, objectId=None):
        
        try:
            j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std)
            j = jsonify(j)
            j.status_code = 200
        except NautilusError as E:
            return self.dts_error(error_name=E.__class__.__name__, message=E.__doc__)
        return j
59782
def get_id2upper(objs):
    """"""
    id2upper = {}
    for obj in objs:
        _get_id2upper(id2upper, obj.item_id, obj)
    return id2upper
1361477
function(count){
      var result = [];

      if (count)
        for (var objectId in this.items_)
          if (result.push(this.items_[objectId]) >= count)
            break;

      return result;
    }
955964
def deserialize(to_deserialize, *args, **kwargs):
    
    if isinstance(to_deserialize, string_types):
        if re.match('^[0-9a-f]{24}$', to_deserialize):
            return ObjectId(to_deserialize)
        try:
            return bson_loads(to_deserialize, *args, **kwargs)
        except:
            return bson_loads(bson_dumps(to_deserialize), *args, **kwargs)
    else:
        return bson_loads(bson_dumps(to_deserialize), *args, **kwargs)
457664
def _onDocstring( self, docstr, line ):
        "  "
        if self.objectsStack:
            self.objectsStack[ -1 ].docstring = \
                                 Docstring( trim_docstring( docstr ), line )
            return

        self.docstring = Docstring( trim_docstring( docstr ), line )
        return
38011
def arbitrary_object_to_string(a_thing):
    """"""
    # is it None?
    if a_thing is None:
        return ''
    # is it already a string?
    if isinstance(a_thing, six.string_types):
        return a_thing
    if six.PY3 and isinstance(a_thing, six.binary_type):
        try:
            return a_thing.decode('utf-8')
        except UnicodeDecodeError:
            pass
    # does it have a to_str function?
    try:
        return a_thing.to_str()
    except (AttributeError, KeyError, TypeError):
        # AttributeError - no to_str function?
        # KeyError - DotDict has no to_str?
        # TypeError - problem converting
        # nope, no to_str function
        pass
    # is this a type proxy?
    try:
        return arbitrary_object_to_string(a_thing.a_type)
    except (AttributeError, KeyError, TypeError):
        #
        # nope, no a_type property
        pass
    # is it a built in?
    try:
        return known_mapping_type_to_str[a_thing]
    except (KeyError, TypeError):
        # nope, not a builtin
        pass
    # is it something from a loaded module?
    try:
        if a_thing.__module__ not in ('__builtin__', 'builtins', 'exceptions'):
            if a_thing.__module__ == "__main__":
                module_name = (
                    sys.modules['__main__']
                    .__file__[:-3]
                    .replace('/', '.')
                    .strip('.')
                )
            else:
                module_name = a_thing.__module__
            return "%s.%s" % (module_name, a_thing.__name__)
    except AttributeError:
        # nope, not one of these
        pass
    # maybe it has a __name__ attribute?
    try:
        return a_thing.__name__
    except AttributeError:
        # nope, not one of these
        pass
    # punt and see what happens if we just cast it to string
    return str(a_thing)
594605
def tostring(element):
    """"""
    rv = []

    def serializeElement(element):
        if not hasattr(element, "tag"):
            if element.docinfo.internalDTD:
                if element.docinfo.doctype:
                    dtd_str = element.docinfo.doctype
                else:
                    dtd_str = "<!DOCTYPE %s>" % element.docinfo.root_name
                rv.append(dtd_str)
            serializeElement(element.getroot())

        elif element.tag == comment_type:
            rv.append("<!--%s-->" % (element.text,))

        else:
            # This is assumed to be an ordinary element
            if not element.attrib:
                rv.append("<%s>" % (element.tag,))
            else:
                attr = " ".join(["%s=\"%s\"" % (name, value)
                                 for name, value in element.attrib.items()])
                rv.append("<%s %s>" % (element.tag, attr))
            if element.text:
                rv.append(element.text)

            for child in element:
                serializeElement(child)

            rv.append("</%s>" % (element.tag,))

        if hasattr(element, "tail") and element.tail:
            rv.append(element.tail)

    serializeElement(element)

    return "".join(rv)
792971
def getfieldnamesendswith(idfobject, endswith):
    """"""
    objls = idfobject.objls
    tmp = [name for name in objls if name.endswith(endswith)]
    if tmp == []:
        pass
    return [name for name in objls if name.endswith(endswith)]
164967
function toString( $contentObjectAttribute )
    {
        $objectAttributeContent = $contentObjectAttribute->attribute( 'content' );
        $objectIDList = array();
        foreach( $objectAttributeContent['relation_list'] as $objectInfo )
        {
            $objectIDList[] = $objectInfo['contentobject_id'];
        }
        return implode( '-', $objectIDList );
    }
1238342
function ObjectId(bytes) {
    if (Buffer.isBuffer(bytes)) {
        if (bytes.length != 12) throw new Error("Buffer-based ObjectId must be 12 bytes")
        this.bytes = bytes
    } else if (typeof bytes == 'string') {
        if (bytes.length != 24) throw new Error("String-based ObjectId must be 24 bytes")
        if (!/^[0-9a-f]{24}$/i.test(bytes)) throw new Error("String-based ObjectId must in hex-format:" + bytes)
        this.bytes = fromHex(bytes)
    } else if (typeof bytes !== 'undefined') {
        throw new Error("Unrecognized type: "+bytes)
    } else {
        var timestamp = (Date.now() / 1000) & 0xFFFFFFFF
        inc = ~~inc+1 // keep as integer
        this.bytes = new Buffer([
            timestamp>>24,
            timestamp>>16,
            timestamp>>8,
            timestamp,
            machineAndPid[0],
            machineAndPid[1],
            machineAndPid[2],
            machineAndPid[3],
            machineAndPid[4],
            inc>>16,
            inc>>8,
            inc
        ])
    }
}
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()})
991743
def serialize_all(obj):
        """"""
        if '_hyperparameters' not in dir(obj):
            return {}
        return {k: str(v) for k, v in obj._hyperparameters.items() if v is not None}
318259
def to_string(self):
        """"""


        # RMF: special case defaults for node, edge and graph properties.
        #
        node = quote_if_necessary(self.obj_dict['name'])

        node_attr = list()

        for attr in sorted(self.obj_dict['attributes']):
            value = self.obj_dict['attributes'][attr]
            if value == '':
                value = '""'
            if value is not None:
                node_attr.append(
                    '%s=%s' % (attr, quote_if_necessary(value) ) )
            else:
                node_attr.append( attr )


        # No point in having nodes setting any defaults if the don't set
        # any attributes...
        #
        if node in ('graph', 'node', 'edge') and len(node_attr) == 0:
            return ''

        node_attr = ', '.join(node_attr)

        if node_attr:
            node += ' [' + node_attr + ']'

        return node + ';'
857753
static function fetchListByContentObjectId( $objectId )
    {
        $conds = array( 'object_id' => $objectId );
        $objectList = eZPersistentObject::fetchObjectList( self::definition(), null, $conds );
        return $objectList;
    }