コード例 #1
0
def loadSettings(settings, file, section="default"):
    '''Load settings from file.
    
     Keyword arguments:
     settings - default settings from parrent class 
     file - abs path to file
     section - section name (default = default)
     '''
    ini_parser = SafeConfigParser()
    ini_parser.read(makePath(file))

    if not section in ini_parser.sections():
        msg = "V souboru %s nenalezena sekce %s." % (file, section)
        raise SettingsSectionNotFound(msg)

    for key in settings.keys():
        tmp = settings[key]
        if ini_parser.has_option(section, key):
            if type(settings[key]) == int:
                tmp = ini_parser.getint(section, key)
            elif type(settings[key]) == bool:
                tmp = ini_parser.getboolean(section, key)
            else:
                tmp = ini_parser.get(section, key)

        settings[key] = tmp
コード例 #2
0
def loadSettings(settings, file, section = "default"):
    '''Load settings from file.
    
     Keyword arguments:
     settings - default settings from parrent class 
     file - abs path to file
     section - section name (default = default)
     '''
    ini_parser = SafeConfigParser()
    ini_parser.read(makePath(file))
    
    if not section in ini_parser.sections():
        msg = "V souboru %s nenalezena sekce %s." %(file, section)
        raise SettingsSectionNotFound(msg)
    
    for key in settings.keys():
            tmp = settings[key]
            if ini_parser.has_option(section, key):
                if type(settings[key]) == int:
                    tmp = ini_parser.getint(section, key)
                elif type(settings[key]) == bool:
                    tmp = ini_parser.getboolean(section, key)
                else:
                    tmp = ini_parser.get(section, key)

            settings[key] = tmp
コード例 #3
0
    def createDbCache(self, filename, ext=".db"):
        '''using dataabse as cachce'''
        if not ext.startswith("."):
            ext = "." + ext

        if self._cache:
            self._cache.dumpCache()

        createFolderStruc(self.cacheFolder)

        path = makePath(os.path.join(self.cacheFolder, filename) + ext)
コード例 #4
0
    def createDbCache(self, filename, ext = ".db"):
        '''using dataabse as cachce'''
        if not ext.startswith("."):
            ext = "." + ext
            
        if self._cache:
            self._cache.dumpCache()
        

        createFolderStruc(self.cacheFolder)
            
        path = makePath(os.path.join(self.cacheFolder,filename)+ext)
コード例 #5
0
    def createPersistenCache(self, filename, ext=".cache"):
        '''Create persistent cache - dict. On cache delete is stored as pickle on hdd.'''
        if not ext.startswith("."):
            ext = "." + ext

        if self._cache:
            self._cache.dumpCache()

        createFolderStruc(self.cacheFolder)

        path = makePath(os.path.join(self.cacheFolder, filename) + ext)
        self._cache = _SimpleCache(path, persistent=True)

        pass
コード例 #6
0
    def createPersistenCache(self, filename, ext = ".cache"):
        '''Create persistent cache - dict. On cache delete is stored as pickle on hdd.'''
        if not ext.startswith("."):
            ext = "." + ext
            
        if self._cache:
            self._cache.dumpCache()
        

        createFolderStruc(self.cacheFolder)
            
        path = makePath(os.path.join(self.cacheFolder,filename)+ext)
        self._cache = _SimpleCache(path, persistent = True)
           
        pass
コード例 #7
0
 def __init__(self, cacheFolder=".cacheFiles"):
     self._cache = None
     self.cacheFolder = makePath(cacheFolder)
コード例 #8
0
 def __init__(self, cacheFolder=".cacheFiles"):
     self._cache = None
     self.cacheFolder = makePath(cacheFolder)