def __init__(self, filename, flag, key_type='str', dump_method='json', cached=True, writeback=False): DbfilenameShelf.__init__(self, filename, flag, -1, writeback) cached = (flag is 'r') and cached self._setup_methods(cached, key_type, dump_method)
def __init__(self, fname=None, tmpdir=None, persistent=False): if fname is None: #get tmp directory self._tmpdir = TMPDIR if tmpdir is None else tmpdir #create tmp file for db fd, self.filename = mkstemp('', PREFIX, dir=self._tmpdir) os.close(fd); os.unlink(self.filename) #create a shelf in the db DbfilenameShelf.__init__(self, self.filename, flag='n', protocol=-1) if not persistent: register_tmp_file(self.filename) else: self._tmpdir = os.path.dirname(fname) self.filename = fname DbfilenameShelf.__init__(self, self.filename, flag='w', protocol=-1)
def __init__(self, name, logger): filename = os.environ['HOME'] + '/.lox/.' + name + '.cache' DbfilenameShelf.__init__(self, filename, protocol=2, writeback=True) api = LoxApi(name) api_version = api.version() config_dir = config.settings[name]['local_dir'] try: my_dir = self.get('local_dir',None) assert config_dir == my_dir my_version = self.get('version',None) assert api_version == my_version except AssertionError: # Cache is considered not safe, so re-initialized logger.warn("Initializing cache") self.clear() self[u'local_dir'] = config_dir self[u'version'] = api_version
def __init__(self, args_sequence: Sequence, as_input_cache=False): Cache.__init__(self, args_sequence) try: if as_input_cache: # noinspection PyUnresolvedReferences DbfilenameShelf.__init__(self, filename=self.filename, flag='r') else: # noinspection PyUnresolvedReferences DbfilenameShelf.__init__(self, filename=self.filename, flag=self.FILE_CACHE_MODE[self.mode], writeback=self.in_memory_cache) except IOError as e: self._critical('Error while opening cache', ExitCode.FILE_ERROR, e) # noinspection PyUnresolvedReferences self._debug(f' Initialized', header=f'Cache "{self.filename}"')
def __init__(self, fname=None, tmpdir=None, persistent=False): if fname is None: #get tmp directory self._tmpdir = TMPDIR if tmpdir is None else tmpdir #create tmp file for db fd, self.filename = mkstemp('', PREFIX, dir=self._tmpdir) os.close(fd) os.unlink(self.filename) #create a shelf in the db DbfilenameShelf.__init__(self, self.filename, flag='n', protocol=-1) if not persistent: register_tmp_file(self.filename) else: self._tmpdir = os.path.dirname(fname) self.filename = fname DbfilenameShelf.__init__(self, self.filename, flag='w', protocol=-1)
def _reset(self): # noinspection PyUnresolvedReferences DbfilenameShelf.__init__(self, filename=self.filename, flag='n', writeback=self.in_memory_cache)
def sync_now(self): filename = self.filename self.close() DbfilenameShelf.__init__(self, filename)
def __init__(self, filename): DbfilenameShelf.__init__(self, filename) self.filename = filename
def _open(self): DbfilenameShelf.__init__( self, os.path.join(self.get_database_path(self.config["path"]), "shelfdb.db"), )
def __init__(self, *args, **kwargs): DbfilenameShelf.__init__(self, *args, **kwargs)
def __init__(self, filename): DbfilenameShelf.__init__(self,filename)
def __init__(self, filename, protocol=2, writeback=True): DbfilenameShelf.__init__(self, filename, protocol=protocol, writeback=writeback)
def __init__(self, filename): self.filename = filename DbfilenameShelf.__init__(self, filename, flag='r', protocol=-1)