From: Cédric Aguerre Date: Tue, 29 Apr 2014 16:13:04 +0000 (+0200) Subject: fix bug with quotes X-Git-Tag: V7_4_0rc1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2924ea310bf0e5adf256b48a32d0c8d2a7fdbc4;p=modules%2Fkernel.git fix bug with quotes --- diff --git a/bin/parseConfigFile.py b/bin/parseConfigFile.py index 76cf1a2cb..3054ed1f3 100644 --- a/bin/parseConfigFile.py +++ b/bin/parseConfigFile.py @@ -32,6 +32,17 @@ ADD_TO_PREFIX = 'ADD_TO_' UNSET_KEYWORD = 'UNSET' +def _expandSystemVariables(key, val): + expandedVal = os.path.expandvars(val) # expand environment variables + # Search for not expanded variables (i.e. non-existing environment variables) + pattern = re.compile('\${ ( [^}]* ) }', re.VERBOSE) # string enclosed in ${ and } + expandedVal = pattern.sub(r'', expandedVal) # remove matching patterns + + if not "DLIM8VAR" in key: # special case: DISTENE licence key can contain double clons (::) + expandedVal = _trimColons(expandedVal) + return expandedVal +# + # :TRICKY: So ugly solution... class MultiOptSafeConfigParser(ConfigParser.SafeConfigParser): def __init__(self): @@ -106,7 +117,8 @@ class MultiOptSafeConfigParser(ConfigParser.SafeConfigParser): optval = optval.strip() # ADD THESE LINES splittedComments = optval.split('#') - optval = splittedComments[0].strip().strip("'").strip('"') + s = _expandSystemVariables(optname, splittedComments[0]) + optval = s.strip().strip("'").strip('"') #if len(splittedComments) > 1: # optval += " #" + " ".join(splittedComments[1:]) # END OF ADD @@ -192,13 +204,7 @@ def __processConfigFile(config, reserved = [], filename="UNKNOWN FILENAME"): elif key == UNSET_KEYWORD: unsetVariables += val.replace(',', ' ').split() else: - expandedVal = os.path.expandvars(val) # expand environment variables - # Search for not expanded variables (i.e. non-existing environment variables) - pattern = re.compile('\${ ( [^}]* ) }', re.VERBOSE) # string enclosed in ${ and } - expandedVal = pattern.sub(r'', expandedVal) # remove matching patterns - # Trim colons - if not "DLIM8VAR" in key: # special case: DISTENE licence key can contain double clons (::) - expandedVal = _trimColons(expandedVal) + expandedVal = _expandSystemVariables(key, val) if key in reservedKeys: shortKey = key[len(ADD_TO_PREFIX):]