blob: a89b020eb09cc5cea2cd3702cc1b2606878cfd2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# -*- coding: utf-8 -*-
#TODO : dissociate the db connexion and the objecthandler (probably pass a db connexion as init argument)
import sqlite3
from version import VERSION
class ObjectHandler :
def __init__(self,root,dbhandler) :
self.rootDirectory = root
self.db = dbhandler
if isinstance(self.db,sqlite3.Connection) :
self.db.text_factory = str
self.sql = self.db.cursor()
def childList(self,hash) :
self.sql.execute("select son from structure where hash=?",(hash,))
l = []
for son in self.cursor :
l.append(son[0])
return l
def fileName(self,hash) :
return self.rootDirectory+'objects/'+hash[:2]+'/'+hash[2:]
def appendChild(self,father,son) :
self.sql.execute("insert into structure values (?,?)",(father,son))
self.db.commit()
|