Ejemplo n.º 1
0
def index_count(index_file=config.vdb_bin_index):
    """
    Method to return the number of indexed items
    :param index_file: Index DB file
    :return: Count of the index
    """
    return len(storage.stream_read(index_file))
Ejemplo n.º 2
0
def list_all_occurrence(db):
    """Method to return all data

    :param db: db instance
    :return: List of data stored as occurrences
    """
    return convert_to_occurrence(storage.stream_read(db["db_file"]))
Ejemplo n.º 3
0
def list_all(db):
    """Method to return all data

    :param db: db instance
    :return: List of data stored
    """
    return storage.stream_read(db["db_file"])
Ejemplo n.º 4
0
def test_create(test_vuln_data):
    with tempfile.NamedTemporaryFile(delete=False) as fp:
        data = storage.store(test_vuln_data, db_file=fp.name)
        assert data
        fp.flush()

        datas = storage.stream_read(db_file=fp.name)
        assert len(datas) > len(test_vuln_data)
        fp.close()
Ejemplo n.º 5
0
def get(db_file=config.vdb_bin_file, index_file=config.vdb_bin_index):
    """Get database instance

    :param db_file: DB file
    :param index_file: Index file
    :return: DB and index file
    """
    global index_data, vendor_index_data
    index_data, vendor_index_data = build_index(
        storage.stream_read(index_file))
    return {"db_file": db_file, "index_file": index_file}
Ejemplo n.º 6
0
def store(db, datas):
    """Store data in the table

    :param table: Table instance
    :param datas: Data list to store
    :return: Stored packed documents
    """
    global index_data, vendor_index_data
    docs = storage.store(datas,
                         db_file=db["db_file"],
                         index_file=db["index_file"])
    # Re-read the index
    index_data, vendor_index_data = build_index(
        storage.stream_read(db["index_file"]))
    return docs