示例#1
0
 def isWritable(self, name):
     value = self._connection.fetchOne(
         'SELECT writable FROM PROPERTIES WHERE name=?', (name, ))
     if value.success():
         return Result(True, True if value.content[0] == 1 else False)
     else:
         return Result(False, None)
示例#2
0
 def findAll(self):
     properties = {}
     fetchresult = self._connection.fetchAll(
         'SELECT name, value, writable FROM PROPERTIES ORDER BY name')
     if fetchresult.success:
         with closing(fetchresult.content) as cursor:
             for record in cursor:
                 properties[record[0]] = (record[1],
                                          True if record[2] == 1 else False)
     return Result(True, properties)
示例#3
0
 def list(self):
     return Result(True, list(self._values.keys()))
示例#4
0
 def clear(self):
     self._values = {}
     return Result(True, list(self._values.keys()))
示例#5
0
 def unselect(self):
     cle = list(self._values.keys())[-1]
     self._values.pop(cle)
     return Result(True, list(self._values.keys()))
示例#6
0
 def select(self, number):
     self._values[number] = number
     return Result(True, list(self._values.keys()))
示例#7
0
 def unset(self, name):
     if self.isWritable(name):
         return self.uncheckedUnset(name)
     else:
         return Result(False, None)
示例#8
0
 def set(self, name, value):
     writable = self.isWritable(name)
     if writable.success() and writable.content:
         return self.uncheckedSet(name, value, True)
     else:
         return Result(False, None)