Example #1
0
 def load_from_store(self):
     if not self._store:
         raise AttributeError("No datastore defined!")
     if self._store.has_blob('all_keys'):
         data = Serializer.deserialize(self._store.get_blob('all_keys'))
         self.load_from_data(data)
         return True
     elif self._store.has_blob('all_keys_with_undefined'):
         data = Serializer.deserialize(self._store.get_blob('all_keys_with_undefined'))
         self.load_from_data(data,with_undefined = True)
         return True
     else:
         return False
Example #2
0
 def load_config(self):
     config_file = self._path + "/config.json"
     if os.path.exists(config_file):
         with open(config_file, "rb") as config_file:
             self._config = Serializer.deserialize(config_file.read())
     else:
         self._config = {'indexes': {}}
         self.save_config()
Example #3
0
 def load_config(self):
     config_file = self._path+"/config.json"
     if os.path.exists(config_file):
         with open(config_file,"rb") as config_file:
             self._config = Serializer.deserialize(config_file.read())
     else:
         self._config = {
             'indexes' : {}
         }
         self.save_config()
Example #4
0
    def save_to_store(self):
        """Save index to store.

        :raise AttributeError: If no datastore is defined

        """
        if not self._store:
            raise AttributeError('No datastore defined!')
        saved_data = self.save_to_data(in_place=True)
        data = Serializer.serialize(saved_data)
        self._store.store_blob(data, 'all_keys_with_undefined')
Example #5
0
    def save_to_store(self):
        """Save index to store.

        :raise AttributeError: If no datastore is defined

        """
        if not self._store:
            raise AttributeError('No datastore defined!')
        saved_data = self.save_to_data(in_place=True)
        data = Serializer.serialize(saved_data)
        self._store.store_blob(data, 'all_keys_with_undefined')
Example #6
0
    def load_from_store(self):
        """Load index from store.

        :return: Whether index was correctly loaded or not
        :rtype: bool
        :raise AttributeError: If no datastore is defined

        """
        if not self._store:
            raise AttributeError('No datastore defined!')
        if self._store.has_blob('all_keys'):
            data = Serializer.deserialize(self._store.get_blob('all_keys'))
            self.load_from_data(data)
            return True
        elif self._store.has_blob('all_keys_with_undefined'):
            blob = self._store.get_blob('all_keys_with_undefined')
            data = Serializer.deserialize(blob)
            self.load_from_data(data, with_undefined=True)
            return True
        else:
            return False
Example #7
0
    def load_from_store(self):
        """Load index from store.

        :return: Whether index was correctly loaded or not
        :rtype: bool
        :raise AttributeError: If no datastore is defined

        """
        if not self._store:
            raise AttributeError('No datastore defined!')
        if self._store.has_blob('all_keys'):
            data = Serializer.deserialize(self._store.get_blob('all_keys'))
            self.load_from_data(data)
            return True
        elif self._store.has_blob('all_keys_with_undefined'):
            blob = self._store.get_blob('all_keys_with_undefined')
            data = Serializer.deserialize(blob)
            self.load_from_data(data, with_undefined=True)
            return True
        else:
            return False
Example #8
0
 def save_to_store(self):
     if not self._store:
         raise AttributeError("No datastore defined!")
     saved_data = self.save_to_data(in_place=True)
     data = Serializer.serialize(saved_data)
     self._store.store_blob(data, 'all_keys_with_undefined')
Example #9
0
 def save_config(self):
     config_file = self._path+"/config.json"
     with open(config_file,"wb") as config_file:
         config_file.write(Serializer.serialize(self._config))
Example #10
0
 def decode_attributes(self,data):
     return Serializer.deserialize(data)
Example #11
0
 def encode_attributes(self,attributes):
     return Serializer.serialize(attributes)
Example #12
0
 def save_config(self):
     config_file = self._path + "/config.json"
     with open(config_file, "wb") as config_file:
         config_file.write(Serializer.serialize(self._config))
Example #13
0
 def decode_attributes(self, data):
     return Serializer.deserialize(data)
Example #14
0
 def encode_attributes(self, attributes):
     return Serializer.serialize(attributes)