def appendtextindex(table, index_or_dirname, indexname=None, merge=True,
                    optimize=False):
    import whoosh.index

    # deal with polymorphic argument
    if isinstance(index_or_dirname, string_types):
        dirname = index_or_dirname
        index = whoosh.index.open_dir(dirname, indexname=indexname,
                                      readonly=False)
        needs_closing = True
    elif isinstance(index_or_dirname, whoosh.index.Index):
        index = index_or_dirname
        needs_closing = False
    else:
        raise ArgumentError('expected string or index, found %r'
                            % index_or_dirname)

    writer = index.writer()
    try:

        for d in dicts(table):
            writer.add_document(**d)
        writer.commit(merge=merge, optimize=optimize)

    except Exception:
        writer.cancel()
        raise

    finally:
        if needs_closing:
            index.close()
Async version of delete().
dataset/ETHPy150Open alimanfoo/petl/petl/io/whoosh.py/appendtextindex--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/ndb/blobstore.py/BlobInfo.delete_async