コード例 #1
0
    def open(self):
        #  If .db files exist, read them. If not, create them.
        if os.path.isfile('data/City.db') and os.path.isfile(
                'data/Country.db'):
            print 'The pipeline has been opened!'
            self.city = MainBody.fakeopen('data/City.db')
            self.country = MainBody.fakeopen('data/Country.db')

        else:
            print "Have to create db files! Don't panic!"
            print "The pipeline has been opened!"
            self.city = MainBody.fakeopen('data/City.db')
            self.country = MainBody.fakeopen('data/Country.db')
            city_handle = open(self.city_path, 'r')
            country_handle = open(self.country_path, 'r')
            for city in city_handle:
                elm_list = city.split('\t')
                try:
                    self.city[elm_list[2]].append(elm_list)
                except:
                    self.city[elm_list[2]] = [elm_list]

            for country in country_handle:
                elm_list = country.split('\t')
                self.country[elm_list[0]] = elm_list

            self.country.sync()
            self.city.sync()
コード例 #2
0
 def Get(self, key):
     self.db = MainBody.fakeopen(self.filename)
     key = str(key)
     try:
         # Meta data
         return self.db[key]
     finally:
         self.db.sync()
コード例 #3
0
 def Remove(self, key):
     self.db = MainBody.fakeopen(self.filename)
     key = str(key)
     try:
         print self.db.keys()
         if key not in self.db.keys():
             raise LookupError
         del self.db[key]
     except LookupError:
         print "Error: there is no %s exist" %key
     self.db.sync()
コード例 #4
0
 def Put(self, key, data):
     self.db = MainBody.fakeopen(self.filename)
     key = str(key)
     self.db[key] = data
     if key in self.db.keys():
         # print str(key) + " in db"
         print "show db keys after PUT " + key + " " +str(self.db.keys())
     else:
         print str(key) + " not in db"
         return
     self.db.sync()
コード例 #5
0
 def __init__(self, filename):
     self.filename = filename
     self.getdb = MainBody.fakeopen(self.filename)
コード例 #6
0
ファイル: main.py プロジェクト: bomboom/542_Jiaqi_Chen
import MainBody
import concurracy
from timeit import Timer

test = MainBody.fakeopen('cs542.db')
print 'Puting "A" in'
print 'Size: 1048000 Bytes'
test['A'] = bytearray(1048000)
test.sync()
print 'Puting "B" in'
print 'Size: 1048000 Bytes'
test['B'] = bytearray(1048000)
test.sync()
print 'Puting "C" in'
print 'Size: 1048000 Bytes'
test['C'] = bytearray(1048000)
test.sync()
print 'Puting "D" in'
print 'Size: 1048000 Bytes'
test['D'] = bytearray(1048000)
test.sync()
print 'Deleting "B"'
del test['B']
print 'Puting "E" in'
print 'Size: 1048000/2 Bytes'
test['E'] = bytearray(1048000 / 2)
print 'Puting "F" in'
print 'Size: 1048000 Bytes'
test['F'] = bytearray(1048000)
test.sync()
del test['C']
コード例 #7
0
ファイル: main.py プロジェクト: ChanZou/542_Jiaqi_Chen
import MainBody
import concurracy
from timeit import Timer

test = MainBody.fakeopen('cs542.db')
print 'Puting "A" in'
print 'Size: 1048000 Bytes'
test['A'] = bytearray(1048000)
test.sync()
print 'Puting "B" in'
print 'Size: 1048000 Bytes'
test['B'] = bytearray(1048000)
test.sync()
print 'Puting "C" in'
print 'Size: 1048000 Bytes'
test['C'] = bytearray(1048000)
test.sync()
print 'Puting "D" in'
print 'Size: 1048000 Bytes'
test['D'] = bytearray(1048000)
test.sync()
print 'Deleting "B"'
del test['B']
print 'Puting "E" in'
print 'Size: 1048000/2 Bytes'
test['E'] = bytearray(1048000/2)
print 'Puting "F" in'
print 'Size: 1048000 Bytes'
test['F'] = bytearray(1048000)
test.sync()
del test['C']
コード例 #8
0
import MainBody
from timeit import Timer

test = MainBody.fakeopen('Test01.db')
print 'Puting "A" in'
print 'Size: 1048000 Bytes'
test['A'] = bytearray(1048000)
test.sync()
print 'Puting "B" in'
print 'Size: 1048000 Bytes'
test['B'] = bytearray(1048000)
test.sync()
print 'Puting "C" in'
print 'Size: 1048000 Bytes'
test['C'] = bytearray(1048000)
test.sync()
print 'Puting "D" in'
print 'Size: 1048000 Bytes'
test['D'] = bytearray(1048000)
test.sync()
print 'Deleting "B"'
del test['B']
print 'Puting "E" in'
print 'Size: 1048000/2 Bytes'
test['E'] = bytearray(1048000 / 2)
print 'Puting "F" in'
print 'Size: 1048000 Bytes'
test['F'] = bytearray(1048000)
test.sync()
del test['C']
print 'Deleting "C"'
コード例 #9
0
 def __init__(self, testing):
     super().__init__()
     self.setupUi(self)
     self.backk = MainBody.MainWindow(self)
     self.pushButton_1.pressed.connect(self.exitt)
     self.showScore(testing)
コード例 #10
0
 def __init__(self, filename):
     self.filename = filename
     self.db = MainBody.open(self.filename)
     self.lock = Lock()