import contextlib


from idb.idapython import IDAPython


@contextlib.contextmanager
def from_file(path):
    # break import cycle
    import idb.fileformat

    with open(path, 'rb') as f:
        buf = memoryview(f.read())
        db = idb.fileformat.IDB(buf)
        db.vsParse(buf)
        yield db

@@ -296,8 +296,177 @@
 ield db%0A
+%0A%0Adef from_buffer(buf):%0A    # break import cycle%0A    import idb.fileformat%0A%0A    buf = memoryview(buf)%0A    db = idb.fileformat.IDB(buf)%0A    db.vsParse(buf)%0A    return db%0A

add from_buffer constructor