Exemple #1
0
def parse_metajson_file(file_path):
    with open(file_path) as metajson_file:
        metajson = jsonbson.load_json_file(metajson_file)
        if "records" in metajson:
            for record in metajson["records"]:
                if record:
                    yield metajson_service.load_dict(record)
def get_document_by_mongo_id(corpus, mongo_id):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][DOCUMENTS].find_one({'_id': ObjectId(mongo_id)})
    if result:
        return metajson_service.load_dict(result)
    else:
        raise exceptions.metajsonprc_error(3)
def get_type(corpus, type_id):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][TYPES].find_one({"type_id": type_id})
    if result:
        return metajson_service.load_dict(result)
    else:
        return None
def get_field(corpus, rec_type):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][FIELDS].find_one({"rec_type": rec_type})
    if result:
        return metajson_service.load_dict(result)
    else:
        return None
Exemple #5
0
def get_document_by_mongo_id(corpus, mongo_id):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][DOCUMENTS].find_one(
        {'_id': ObjectId(mongo_id)})
    if result:
        return metajson_service.load_dict(result)
    else:
        raise exceptions.metajsonprc_error(3)
Exemple #6
0
def get_type(corpus, type_id):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][TYPES].find_one(
        {"type_id": type_id})
    if result:
        return metajson_service.load_dict(result)
    else:
        return None
Exemple #7
0
def get_field(corpus, rec_type):
    if not corpus:
        corpus = default_corpus
    result = mongodb[database_name(corpus)][FIELDS].find_one(
        {"rec_type": rec_type})
    if result:
        return metajson_service.load_dict(result)
    else:
        return None