Example #1
0
 def delete_data(self, varname: str):
     with self.metadataset.lock_data(varname):
         if varname not in self.varset:
             raise NotFoundError(f'{varname} not found')
         self.recyclebin.discard(varname, self.varset[varname])
         self.varset.pop(varname)
         self.metadataset.delete_data(varname)
Example #2
0
 def delete_data(self, key: str, provider='unknown'):
     with self.metadataset.lock_data(key):
         if key not in self.varset:
             raise NotFoundError(f'{key} not found')
         self.recyclebin.discard(key, self.varset[key])
         self.varset.pop(key)
         self.metadataset.delete_data(key)
Example #3
0
 def modify_data(self, key: str, modified_by: str):
     if key not in self:
         raise NotFoundError(f'no such data {key}')
     info = self[key]
     info['modification_time'].append(time.time())
     info['modified_by'].append(modified_by)
     info['synchronised'] = False
     info['deleted'] = False
Example #4
0
 def read_data(self, key: str) -> dict:
     with self.metadataset.lock_data(key):
         if key not in self.metadataset or self.metadataset[key]['deleted']:
             raise NotFoundError(f'{key} not found')
         metadata = self.metadataset[key]
         if not metadata['synchronised']:
             data = self.converter.convert_to_data(
                 self.varset.get_var(key))
             self.dataset.synchronise(key, data)
             self.metadataset.synchronise_data(key)
         return self.dataset.read(key)
Example #5
0
 def restore(self, index: int, var_to_discard=None) -> tuple:
     # for the case where variables with same name
     # exist in workspace and recycle bin, if you
     # restore the variable in recycle bin, you have
     # to discard the variable in the workspace
     if index >= len(self):
         raise NotFoundError(f'{index} out of limit')
     varname, var_to_restore = self[index]
     self.pop(index)
     if var_to_discard is not None:
         self.discard(varname, var_to_discard)
     return varname, var_to_restore
Example #6
0
 def read_data(self, varname: str) -> dict:
     with self.metadataset.lock_data(varname):
         if varname not in self.metadataset or self.metadataset[varname][
                 'deleted']:
             raise NotFoundError(f'{varname} not found')
         metadata = self.metadataset[varname]
         if not metadata['synchronised']:
             data = self.converter.convert_to_data(
                 self.varset.get_var(varname))
             self.dataset.synchronise(varname, data)
             self.metadataset.synchronise_data(varname)
         return self.dataset.read(varname)
Example #7
0
 def redo(self, key):
     with self.metadataset.lock_data(key):
         if key not in self.historyset:
             raise NotFoundError(f'{key} has no history')
         variable = self.historyset.stepforward(key)
         self.varset.set_var(key, variable)
Example #8
0
 def cancel(self, key):
     with self.metadataset.lock_data(key):
         if key not in self.historyset:
             raise NotFoundError(f'{key} has no history')
         variable = self.historyset.stepback(key, self.varset[key])
         self.varset.set_var(key, variable)
Example #9
0
 def get_var(self, varname: str):
     if varname not in self.varset:
         raise NotFoundError(f'{varname} not found')
     return self.varset[varname]
Example #10
0
 def update(self, key: str, **info):
     if key not in self or self[key]['deleted']:
         raise NotFoundError(f'no such data {key}')
     self[key].update(info)
Example #11
0
 def synchronise_data(self, key: str):
     if key not in self or self[key]['deleted']:
         raise NotFoundError(f'no such data {key}')
     self[key]['synchronised'] = True
Example #12
0
 def restore_data(self, key: str):
     if key not in self:
         raise NotFoundError(f'no such data {key}')
     self[key]['deleted'] = False
Example #13
0
 def get_data_info(self, key: str) -> dict:
     if key not in self.metadataset:
         raise NotFoundError(f'{key} not found')
     return self.metadataset[key]
Example #14
0
 def get_data_info(self, varname: str) -> dict:
     if varname not in self.metadataset:
         raise NotFoundError(f'{varname} not found')
     return self.metadataset[varname]
Example #15
0
 def stepforward(self, key: str):
     if key not in self:
         raise NotFoundError(f'{key} not found in history')
     history = self[key]
     return history.stepforward()
Example #16
0
 def stepback(self, key: str, var):
     if key not in self:
         raise NotFoundError(f'{key} not found in history')
     history = self[key]
     return history.stepback(var)
Example #17
0
 def cancel(self, varname):
     with self.metadataset.lock_data(varname):
         if varname not in self.historyset:
             raise NotFoundError(f'{varname} has no history')
         variable = self.historyset.stepback(varname, self.varset[varname])
         self.varset.set_var(varname, variable)
Example #18
0
 def update_data_info(self, varname: str, **info):
     with self.metadataset.lock_data(varname):
         if varname not in self.metadataset:
             raise NotFoundError(f'{varname} not found')
         self.metadataset.update(varname, **info)
Example #19
0
 def get_var(self, key: str):
     if key not in self.varset:
         raise NotFoundError(f'{key} not found')
     return self.varset[key]
Example #20
0
 def get_varname(self, index: int):
     if index >= len(self):
         raise NotFoundError(f'{index} out of limit')
     return self[index][0]
Example #21
0
 def update_data_info(self, key: str, **info):
     with self.metadataset.lock_data(key):
         if key not in self.metadataset:
             raise NotFoundError(f'{key} not found')
         self.metadataset.update(key, **info)
Example #22
0
 def redo(self, varname):
     with self.metadataset.lock_data(varname):
         if varname not in self.historyset:
             raise NotFoundError(f'{varname} has no history')
         variable = self.historyset.stepforward(varname)
         self.varset.set_var(varname, variable)