Beispiel #1
0
def change_meta_from_doc(document, data_source_type, data_source_name):
    if document is None:
        raise MissingMetaInformationError('No document!')

    doc_meta = get_doc_meta_object_from_document(document)
    return change_meta_from_doc_meta_and_document(doc_meta, document,
                                                  data_source_type,
                                                  data_source_name)
Beispiel #2
0
def change_meta_from_doc_meta_and_document(doc_meta,
                                           document,
                                           data_source_type,
                                           data_source_name,
                                           doc_id=None):
    if doc_meta is None:
        raise MissingMetaInformationError(
            u"Couldn't guess document type for {}!".format(document))

    doc_id = doc_id or document.get('_id', None)
    if not doc_id:
        raise MissingMetaInformationError(u"No doc ID!!".format(document))
    return ChangeMeta(
        document_id=doc_id or document['_id'],
        data_source_type=data_source_type,
        data_source_name=data_source_name,
        document_type=doc_meta.raw_doc_type,
        document_subtype=doc_meta.subtype,
        domain=doc_meta.domain,
        is_deletion=doc_meta.is_deletion,
    )