Make an ATOM service doc here. The 'collections' parameter is a list of
    dictionaries, with the keys of 'title', 'accept' and 'categories'
    being valid
181963
def makeServiceDocXML(title, collections):
    

    serviceTag = etree.Element("service")
    workspaceTag = etree.SubElement(serviceTag, "workspace")
    titleTag = etree.SubElement(workspaceTag, ATOM + "title", nsmap=ATOM_NSMAP)
    titleTag.text = title
    for collection in collections:
        collectionTag = etree.SubElement(workspaceTag, "collection")
        if 'href' in collection:
            collectionTag.set("href", collection['href'])
        if 'title' in collection:
            colTitleTag = etree.SubElement(
                collectionTag, ATOM + "title", nsmap=ATOM_NSMAP
            )
            colTitleTag.text = collection['title']
        if 'accept' in collection:
            acceptTag = etree.SubElement(collectionTag, "accept")
            acceptTag.text = collection['accept']
    return serviceTag
320177
def get_collection(self, collection_id=None, nav="children", page=None):
        
        return self.call(
            "collections",
            {
                "id": collection_id,
                "nav": nav,
                "page": page
            },
            defaults={
                "id": None,
                "nav": "children",
                "page": 1
            }
        )
1084386
public Element collectionToElement() {
        final Collection collection = this;
        final Element element = new Element("collection", AtomService.ATOM_PROTOCOL);
        element.setAttribute("href", collection.getHref());

        final Element titleElem = new Element("title", AtomService.ATOM_FORMAT);
        titleElem.setText(collection.getTitle());
        if (collection.getTitleType() != null && !collection.getTitleType().equals("TEXT")) {
            titleElem.setAttribute("type", collection.getTitleType(), AtomService.ATOM_FORMAT);
        }
        element.addContent(titleElem);

        // Loop to create <app:categories> elements
        for (final Object element2 : collection.getCategories()) {
            final Categories cats = (Categories) element2;
            element.addContent(cats.categoriesToElement());
        }

        for (final Object element2 : collection.getAccepts()) {
            final String range = (String) element2;
            final Element acceptElem = new Element("accept", AtomService.ATOM_PROTOCOL);
            acceptElem.setText(range);
            element.addContent(acceptElem);
        }

        return element;
    }
287564
def put(self):
        
        params = dict(
            title=self.title or '',
            description=self.description or '',
            document_ids=[str(i.id) for i in self.document_list]
        )
        self._connection.put('projects/%s.json' % self.id, params)
516599
function list(options) {
  return function (req, res) {
    let list,
      listOptions = _.assign({
        prefix: req.uri,
        values: false
      }, options);

    list = db.list(listOptions);

    res.set('Content-Type', 'application/json');
    list.pipe(res);
  };
}
1008713
def _add_scheme():
    
    lists = [
        urllib.parse.uses_relative,
        urllib.parse.uses_netloc,
        urllib.parse.uses_query,
    ]
    for l in lists:
        l.append('mongodb')
720352
def configure_createcollection(self, ns, definition):
        
        paginated_list_schema = self.page_cls.make_paginated_list_schema_class(
            ns,
            definition.response_schema,
        )()

        @self.add_route(ns.collection_path, Operation.CreateCollection, ns)
        @request(definition.request_schema)
        @response(paginated_list_schema)
        @wraps(definition.func)
        def create_collection(**path_data):
            request_data = load_request_data(definition.request_schema)
            # NB: if we don't filter the request body through an explicit page schema,
            # we will leak other request arguments into the pagination query strings
            page = self.page_cls.from_query_string(self.page_schema(), request_data)

            result = definition.func(**merge_data(
                path_data,
                merge_data(
                    request_data,
                    page.to_dict(func=identity),
                ),
            ))

            response_data, headers = page.to_paginated_list(result, ns, Operation.CreateCollection)
            definition.header_func(headers, response_data)
            response_format = self.negotiate_response_content(definition.response_formats)
            return dump_response_data(
                paginated_list_schema,
                response_data,
                headers=headers,
                response_format=response_format,
            )

        create_collection.__doc__ = "Create the collection of {}".format(pluralize(ns.subject_name))
379211
def application_adapter(obj, request):
    
    return {
        'title': obj.title,
        'uri': obj.uri,
        'service_url': obj.service_url,
        'success': obj.success,
        'has_references': obj.has_references,
        'count': obj.count,
        'items': [{
                      'uri': i.uri,
                      'title': i.title
                  } for i in obj.items] if obj.items is not None else None
    }
666374
def _collection(self, key):
    ''''''
    collection = str(key.path)
    if not collection in self._items:
      self._items[collection] = dict()
    return self._items[collection]
503189
function(collection, callback){
  	// Prep the collection name.
  	var colName = collection.name.split('.');
  	var dbName = colName.shift();
  	colName = colName.join('.');

  	var database = amityMongo.db.db(dbName);

  	var options = {
  		name:dbName + '/' + colName,
  		service:feathersMongo({collection:database.collection(collection.name)})
  	};
  	amityMongo.amity_collections.push(options);
  	callback();
	}
864549
function writeCollection(collectionState, action) {
  const { meta, merge = { doc: true, collections: true } } = action;
  if (meta.storeAs) {
    return action.payload.ordered;
  }
  const collectionStateSize = size(collectionState);
  const payloadExists = !!size(action.payload.ordered);

  // Handle doc update (update item in array instead of whole array)
  if (meta.doc && merge.doc && collectionStateSize) {
    // Merge if data already exists
    // Merge with existing ordered array if collection merge enabled
    return modifyDoc(collectionState, action);
  }

  // Merge with existing ordered array (existing as source) if collection merge enabled
  if (collectionStateSize && merge.collections) {
    // Listener response is empty - empty state
    if (!payloadExists) {
      return [];
    }
    // Key existing state collection by id (used to prevent multiple array lookups)
    const existingKeys = collectionState && keyBy(collectionState, 'id');
    // Map new doc data with existing doc data (preserves existing sub-collections)
    return map(action.payload.ordered, newDocObj => {
      const existingDoc = get(existingKeys, newDocObj.id);
      // merge with existing doc if existing doc is not equal
      return !!existingDoc && !isEqual(existingDoc, newDocObj)
        ? { ...existingDoc, ...newDocObj }
        : newDocObj;
    });
  }

  // Handle subcollections (only when storeAs is not being used)
  if (meta.doc && meta.subcollections) {
    const subcollectionConfig = meta.subcollections[0];
    if (!collectionStateSize) {
      // Collection state does not already exist, create it with item containing
      // subcollection
      return [
        {
          id: meta.doc,
          [subcollectionConfig.collection]: action.payload.ordered,
        },
      ];
    }
    // Merge with existing document if collection state exists
    return updateItemInArray(collectionState, meta.doc, item =>
      // check if action contains ordered payload
      payloadExists
        ? // merge with existing subcollection
          {
            ...item,
            [subcollectionConfig.collection]: unionBy(
              get(item, subcollectionConfig.collection, []),
              action.payload.ordered,
              'id',
            ),
          }
        : // remove subcollection if payload is empty
          omit(item, [subcollectionConfig.collection]),
    );
  }

  if (meta.doc && collectionStateSize) {
    // Update item in array
    return updateItemInArray(collectionState, meta.doc, item =>
      mergeObjects(item, action.payload.ordered[0]),
    );
  }

  return action.payload.ordered;
}
1071666
def CheckForPresenceOf(self, reslist):
        ''''''
        if type(reslist) == type(""):
            reslist = [reslist]

        foundRes = {}
        for line in self.lines:
            resname = line[17:20]
            if line[0:4] == "ATOM":
                if resname in reslist:
                    foundRes[resname] = True

        return foundRes.keys()
1031576
def add(self, elem):
        
        if isinstance(elem, self._allowedTypes):
            self._collection.add(elem)
            self._collectedTypes.add(type(elem).__name__)
        else:
            raise CollectionTypeError("{} can only contain '{}', '{}' is not allowed.".format(type(self).__name__, self._allowedTypes, elem))
311722
def _docs(self):
        
        iterdocs = iter(self.docs())
        first = next(iterdocs)
        needs_parsing = False
        if isinstance(first, six.string_types):
            needs_parsing = True
        elif isinstance(first, dict):
            pass
        else:
            raise RuntimeError('Document must be either JSON strings or dict.')
        for doc in itertools.chain([first], iterdocs):
            if needs_parsing:
                doc = json.loads(doc)
            if '_index' not in doc:
                doc['_index'] = self.index
            if '_type' not in doc:
                doc['_type'] = self.doc_type
            yield doc
83490
def merge_join_docs(self, keys):
        

        join = defaultdict(list)

        for key in keys:
            join[key] = self.generate_join_docs_list(
                self.collections_data['left'].get(key, []), self.collections_data['right'].get(key, []))
        return join
1100949
function listItemsService(app) {
    apiService.call(this);
    this.setApp(app);


    var service = this;


    /**
     * Default function used to resolve a result set
     *
     * @param {Error} err   mongoose error
     * @param {Array} docs  an array of mongoose documents or an array of objects
     */
    this.mongOutcome = function(err, docs) {
        if (service.handleMongoError(err))
        {
            service.outcome.success = true;
            service.deferred.resolve(docs);
        }
    };


    /**
     * Resolve a mongoose query, paginated or not
     * This method can be used by the service to resolve a mongoose query
     * The paginate parameter is optional, if not provided, all documents will be resolved to the service promise.
     * the function to use for pagination is the 2nd argument of the getResultPromise() method
     * @see listItemsService.getResultPromise()
     *
     * @param {Query}       find
     * @param {function}    [paginate]      (controller optional function to paginate result)
     * @param {function}    [mongOutcome]   optional function to customise resultset before resolving
     */
    this.resolveQuery = function(find, paginate, mongOutcome) {

        if (!mongOutcome) {
            mongOutcome = this.mongOutcome;
        }

        find.exec(function(err, docs) {
            if (!err && typeof paginate === 'function') {
                return paginate(docs.length, find).exec(mongOutcome);
            }

            return mongOutcome(err, docs);
        });
    };


    /**
     * Services instances must implement
     * this method to resolve or reject the service promise
     * list items services have an additional parameter "paginate", this function will be given as parameter
     * by the controller
     *
     * @see listItemsController.paginate()
     *
     * @param {Object} params
     * @param {function} paginate
     *
     * @return {Promise}
     */
    this.getResultPromise = function(params, paginate) {
        console.log('Not implemented');
        return this.deferred.promise;
    };
}
855971
function Collection (items) {
		this.items = new ok.Items();
		this.start();
		if (items) {
			this.add(items);
		}
		this.init();
	}