Пример #1
0
    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)
Пример #2
0
 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)
Пример #3
0
 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
Пример #4
0
 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}"')
Пример #5
0
 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)
Пример #6
0
 def _reset(self):
     # noinspection PyUnresolvedReferences
     DbfilenameShelf.__init__(self,
                              filename=self.filename,
                              flag='n',
                              writeback=self.in_memory_cache)
Пример #7
0
 def sync_now(self):
     filename = self.filename
     self.close()
     DbfilenameShelf.__init__(self, filename)
Пример #8
0
 def __init__(self, filename):
     DbfilenameShelf.__init__(self, filename)
     self.filename = filename
Пример #9
0
 def _open(self):
     DbfilenameShelf.__init__(
         self,
         os.path.join(self.get_database_path(self.config["path"]),
                      "shelfdb.db"),
     )
Пример #10
0
 def __init__(self, *args, **kwargs):
     DbfilenameShelf.__init__(self, *args, **kwargs)
Пример #11
0
 def __init__(self, filename):
     DbfilenameShelf.__init__(self,filename)
Пример #12
0
    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)
Пример #13
0
 def __init__(self, *args, **kwargs):
     DbfilenameShelf.__init__(self, *args, **kwargs)
Пример #14
0
 def __init__(self, filename, protocol=2, writeback=True):
     DbfilenameShelf.__init__(self, filename, protocol=protocol, writeback=writeback)
Пример #15
0
 def __init__(self, filename):
     self.filename = filename
     DbfilenameShelf.__init__(self, filename, flag='r', protocol=-1)
Пример #16
0
 def __init__(self, filename):
     self.filename = filename
     DbfilenameShelf.__init__(self, filename, flag='r', protocol=-1)