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
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
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)
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)
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
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
def __init__(self, cacheFolder=".cacheFiles"): self._cache = None self.cacheFolder = makePath(cacheFolder)