Beispiel #1
0
class DummyHashIndex(IU_HashIndex):
    def __init__(self,
                 db_path,
                 name,
                 entry_line_format="<32s4sIIcI",
                 *args,
                 **kwargs):
        super(DummyHashIndex, self).__init__(db_path, name, entry_line_format,
                                             *args, **kwargs)
        self.create_key = random_hex_32  # : set the function to create random key when no _id given
        # self.entry_struct=struct.Struct(entry_line_format)

    def update(self, *args, **kwargs):
        return True

    def insert(self, *args, **kwargs):
        return True

    def all(self, *args, **kwargs):
        raise StopIteration

    def get(self, *args, **kwargs):
        raise ElemNotFound

    def get_many(self, *args, **kwargs):
        raise StopIteration

    def delete(self, *args, **kwargs):
        pass

    def make_key_value(self, data):
        return '1', {'_': 1}

    def destroy(self):
        pass

    def _clear_cache(self):
        pass

    def _open_storage(self):
        if not self.storage:
            self.storage = DummyStorage()
        self.storage.open()

    def _create_storage(self):
        if not self.storage:
            self.storage = DummyStorage()
        self.storage.create()
Beispiel #2
0
class DummyHashIndex(IU_HashIndex):
    def __init__(self, db_path, name, entry_line_format="<32s4sIIcI", *args, **kwargs):
        super(DummyHashIndex, self).__init__(db_path, name,
                                             entry_line_format, *args, **kwargs)
        self.create_key = random_hex_32  # : set the function to create random key when no _id given
        # self.entry_struct=struct.Struct(entry_line_format)

    def update(self, *args, **kwargs):
        return True

    def insert(self, *args, **kwargs):
        return True

    def all(self, *args, **kwargs):
        raise StopIteration

    def get(self, *args, **kwargs):
        raise ElemNotFound

    def get_many(self, *args, **kwargs):
        raise StopIteration

    def delete(self, *args, **kwargs):
        pass

    def make_key_value(self, data):
        return '1', {'_': 1}

    def destroy(self):
        pass

    def _clear_cache(self):
        pass

    def _open_storage(self):
        if not self.storage:
            self.storage = DummyStorage()
        self.storage.open()

    def _create_storage(self):
        if not self.storage:
            self.storage = DummyStorage()
        self.storage.create()
Beispiel #3
0
 def _create_storage(self):
     if not self.storage:
         self.storage = DummyStorage()
     self.storage.create()
Beispiel #4
0
 def _open_storage(self):
     if not self.storage:
         self.storage = DummyStorage()
     self.storage.open()
Beispiel #5
0
 def _create_storage(self):
     if not self.storage:
         self.storage = DummyStorage()
     self.storage.create()
Beispiel #6
0
 def _open_storage(self):
     if not self.storage:
         self.storage = DummyStorage()
     self.storage.open()