Example #1
0
 def erase(self):
     try:
         if isfile(self.path):
             fh = codecs.open(self.path, 'w+',encoding = "ISO-8859-1")
             towrite = {}
             fh.write(JSONEncoder(encoding = "ISO-8859-1").encode(towrite))
             dataFormat.__init__(self, self.order)
         else:
             return -1
     except IOError:
         return -1
Example #2
0
 def __init__(self,order,path):
     dataFormat.__init__(self, order)
     self.order = order
     self.tablename = path
     self.path = abspath(join(dirname(__file__), path))
     if isfile(self.path):            
         try:
             fh = codecs.open(self.path,'r',encoding = "ISO-8859-1" )
             t = fh.readline()
             j = JSONDecoder(encoding = "ISO-8859-1").decode(t)
             for item in j:
                 formated = JSONDecoder(encoding = "ISO-8859-1").decode(j[item])
                 formated2 = JSONDecoder(encoding = "ISO-8859-1").decode(item)
                 self.insert(formated2, formated)
         except IOError:
             print("Table not found")
         else:
             fh.close()
     else:
         fh = codecs.open(self.path,'w+',encoding = "ISO-8859-1" )
         fh.write('{}')
         fh.close()
Example #3
0
 def insert (self,key,data):
     if self.get(key) == None:
         dataFormat.insert(self, key, data)
         return 0 
     return -1