From 7945c0daad7d2e3b8380c18b7d080e54e0a948ed Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 30 Jul 2010 09:29:24 +0200 Subject: Project creation. --- .gitignore | 1 + __init__.py | 3 ++ object.py | 28 +++++++++++++ permission.py | 45 +++++++++++++++++++++ .../4786341468f1bb861b8ae2cd6dc0a2c582bf5da5 | 1 + .../71f57e14acfdc04b2fe6ed5e2b4dc4e04558dea9 | 1 + users/thibaut/db.sql | Bin 0 -> 2048 bytes .../ed10ca5a70af5dfbd943667ec2b9ee857ee2a148 | 1 + version.py | 5 +++ 9 files changed, 85 insertions(+) create mode 100644 .gitignore create mode 100644 __init__.py create mode 100644 object.py create mode 100644 permission.py create mode 100644 users/thibaut/4786341468f1bb861b8ae2cd6dc0a2c582bf5da5 create mode 100644 users/thibaut/71f57e14acfdc04b2fe6ed5e2b4dc4e04558dea9 create mode 100644 users/thibaut/db.sql create mode 100644 users/thibaut/ed10ca5a70af5dfbd943667ec2b9ee857ee2a148 create mode 100644 version.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..faaaf79 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + + diff --git a/object.py b/object.py new file mode 100644 index 0000000..a89b020 --- /dev/null +++ b/object.py @@ -0,0 +1,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() + diff --git a/permission.py b/permission.py new file mode 100644 index 0000000..310cef2 --- /dev/null +++ b/permission.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +#TODO : move the globals to a config file (use the config file parser module) +PERM_LIST=['READ','MODIFY','APPEND'] #just add a string here to define a new permission +PERMS = len(PERM_LIST) +MAX = (1< MAX) or (init < 0) : + raise PermissionError('Permission int not in correct range') + result = [] + for shift in range(PERMS-1,-1,-1) : + if init>>shift : + result.append(PERM_LIST[shift]) + init = init-(1<