Commit 3a87579a authored by Zhukov, Alexander P's avatar Zhukov, Alexander P
Browse files

Working on ranges

parent 790db7db
......@@ -15,6 +15,6 @@ from read_storage import BinaryStorage
file = BinaryStorage('/data/BinStorage/test.bin')
\ No newline at end of file
......@@ -30,10 +30,21 @@ class BinaryStorage:
def read(self):
return BinaryStorage.read_record(self.file)
def __getitem__(self, key):
def readAt(self, key):
offset = self.rec_table[key]
return BinaryStorage.read_record(self.file)
def __getitem__(self, key):
if isinstance(key,slice):
return [self.readAt(i) for i in range(key.start,key.stop,key.step)]
return self.readAt(key)
def __len__(self):
return len(self.rec_table)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment