From 0450df8a77ed4ab977fdfeb099523f982a9af5fd Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 31 May 2010 08:13:08 +0000 Subject: [PATCH] added kb.cache for storing cached results (e.g. kb.cache.regex for storing compiled regular expressions and kb.cache.md5 for storing precalculated MD5 values during '--users --common-prediction' session) --- lib/core/common.py | 11 +++-------- lib/core/option.py | 5 +++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 52ea24d12..3e7ea6d00 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -76,8 +76,6 @@ from lib.core.settings import SQLITE_ALIASES from lib.core.settings import ACCESS_ALIASES from lib.core.settings import FIREBIRD_ALIASES -__compiledRegularExpressions = {} - def paramToDict(place, parameters=None): """ Split the parameters into names and values, check if these parameters @@ -1305,14 +1303,11 @@ def getCompiledRegex(regex, *args): Returns compiled regular expression and stores it in cache for further usage """ - - global __compiledRegularExpressions - - if (regex, args) in __compiledRegularExpressions: - return __compiledRegularExpressions[(regex, args)] + if (regex, args) in kb.cache.regex: + return kb.cache.regex[(regex, args)] else: retVal = re.compile(regex, *args) - __compiledRegularExpressions[(regex, args)] = retVal + kb.cache.regex[(regex, args)] = retVal return retVal def getPartRun(): diff --git a/lib/core/option.py b/lib/core/option.py index bf1967a57..ac80e22a7 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -928,6 +928,11 @@ def __setKnowledgeBaseAttributes(): kb.absFilePaths = set() kb.bannerFp = advancedDict() + + kb.cache = advancedDict() + kb.cache.regex = {} + kb.cache.md5 = {} + kb.commonOutputs = None kb.data = advancedDict()