def add_to_collections(self, coll, data_provider=None): def _normalize(value): """Replaced whitespace with underscores""" return value.replace(" ", "__") if data_provider is None: data_provider = self.contributor["name"] couch_id_str = "%s--%s" % (data_provider, coll["title"]) _id = _normalize(couch_id_builder(self.provider, couch_id_str)) id = hashlib.md5(_id.encode("utf-8")).hexdigest() at_id = "http://dp.la/api/collections/" + id coll_to_update = coll.copy() coll_to_update.update({ "_id": _id, "id": id, "@id": at_id, "ingestType": "collection" }) desc = coll_to_update.get("description") if desc and isinstance(desc, dict): if 'dc' in desc.keys(): coll_to_update["description"] = getprop( coll_to_update, "description/dc/description") self.collections[coll_to_update["title"]] = coll_to_update
def add_to_collections(self, coll, data_provider=None): def _normalize(value): """Replaced whitespace with underscores""" return value.replace(" ", "__") if data_provider is None: data_provider = self.contributor["name"] couch_id_str = "%s--%s" % (data_provider, coll["title"]) _id = _normalize( couch_id_builder(self.provider, couch_id_str) ) id = hashlib.md5(_id.encode("utf-8")).hexdigest() at_id = "http://dp.la/api/collections/" + id coll_to_update = coll.copy() coll_to_update.update({ "_id" : _id, "id": id, "@id": at_id, "ingestType": "collection" }) desc = coll_to_update.get("description") if desc and isinstance(desc, dict): if 'dc' in desc.keys(): coll_to_update["description"] = getprop(coll_to_update, "description/dc/description") self.collections[coll_to_update["title"]] = coll_to_update
def create_collection_records(self): if self.collections: for set_spec in self.collections.keys(): _id = couch_id_builder(self.provider, set_spec) id = hashlib.md5(_id).hexdigest() at_id = "http://dp.la/api/collections/" + id self.collections[set_spec]["id"] = id self.collections[set_spec]["_id"] = _id self.collections[set_spec]["@id"] = at_id self.collections[set_spec]["ingestType"] = "collection"
def create_collection_record(self, hid, title): if hid not in self.collections: _id = couch_id_builder(self.provider, hid) id = hashlib.md5(_id).hexdigest() at_id = "http://dp.la/api/collections/" + id self.collections[hid] = { "id": id, "_id": _id, "@id": at_id, "title": title, "ingestType": "collection" }
def add_to_collections(self, coll_title, data_provider=None): def _normalize(value): """Replaced whitespace with underscores""" return value.replace(" ", "_") if data_provider is None: data_provider = self.contributor["name"] couch_id_str = "%s--%s" % (data_provider, coll_title) _id = _normalize(couch_id_builder(self.provider, couch_id_str)) id = hashlib.md5(_id.encode("utf-8")).hexdigest() at_id = "http://dp.la/api/collections/" + id self.collections[coll_title] = { "_id": _id, "id": id, "@id": at_id, "title": coll_title, "ingestType": "collection" }
def add_to_collections(self, coll_title, data_provider=None): def _normalize(value): """Replaced whitespace with underscores""" return value.replace(" ", "_") if data_provider is None: data_provider = self.contributor["name"] couch_id_str = "%s--%s" % (data_provider, coll_title) _id = _normalize( couch_id_builder(self.provider, couch_id_str) ) id = hashlib.md5(_id.encode("utf-8")).hexdigest() at_id = "http://dp.la/api/collections/" + id self.collections[coll_title] = { "_id" : _id, "id": id, "@id": at_id, "title": coll_title, "ingestType": "collection" }