def from_key(cls, key): logger.debug("Getting block %s from database", hex(key)) with blocks as con: blob = _get(con, key, select="value", frm="hashmap", where="key") size = _get(con, key, select="size" , frm="hashmap", where="key") return cls(blob, size, key)
def _create_record(self): tuple = os.path.basename(self.path), self.path with snapshot as con: con.execute("REPLACE INTO file(name, path) VALUES(?, ?)", tuple) return _get(con, self.path, select="id", frm="file", where="path")
def from_path(cls, path): with snapshot as con: id = _get(con, path, select="id", frm="file", where="path") return cls(path, id)
def from_id(cls, id): with snapshot as con: path = _get(con, id, select="path", frm="file", where="id") return cls(path, id)