Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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")
Exemplo n.º 3
0
    def from_path(cls, path):
        with snapshot as con:
            id = _get(con, path, select="id", frm="file", where="path")

        return cls(path, id)
Exemplo n.º 4
0
    def from_id(cls, id):
        with snapshot as con:
            path = _get(con, id, select="path", frm="file", where="id")

        return cls(path, id)