X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bin%2FparseConfigFile.py;h=20d782c8cba342b2895a23a615e983beae410bfc;hb=6287d4be648abf1fc820fbfd4c3cc8ba5422436b;hp=69c3e2acd741bb362f820e32da0306f02c62931d;hpb=39b7aec84a009a8a1946ea7b8e50c066f1cfa1f3;p=modules%2Fkernel.git diff --git a/bin/parseConfigFile.py b/bin/parseConfigFile.py index 69c3e2acd..20d782c8c 100644 --- a/bin/parseConfigFile.py +++ b/bin/parseConfigFile.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,7 @@ import logging import re from io import StringIO import subprocess +import collections from salomeContextUtils import SalomeContextException #@UnresolvedImport logging.basicConfig() @@ -30,7 +31,8 @@ logConfigParser = logging.getLogger(__name__) ADD_TO_PREFIX = 'ADD_TO_' UNSET_KEYWORD = 'UNSET' - +# variables defined in this section are set only if not already defined +DEFAULT_VARS_SECTION_NAME = 'SALOME DEFAULT VALUES' def _expandSystemVariables(key, val): expandedVal = os.path.expandvars(val) # expand environment variables @@ -193,6 +195,7 @@ def __processConfigFile(config, reserved = None, filename="UNKNOWN FILENAME"): reserved = [] unsetVariables = [] outputVariables = [] + defaultValues = [] # Get raw items for each section, and make some processing for environment variables management reservedKeys = [ADD_TO_PREFIX+str(x) for x in reserved] # produce [ 'ADD_TO_reserved_1', 'ADD_TO_reserved_2', ..., ADD_TO_reserved_n ] reservedValues = dict([str(i),[]] for i in reserved) # create a dictionary in which keys are the 'ADD_TO_reserved_i' and associated values are empty lists: { 'reserved_1':[], 'reserved_2':[], ..., reserved_n:[] } @@ -217,7 +220,10 @@ def __processConfigFile(config, reserved = None, filename="UNKNOWN FILENAME"): # remove left&right spaces on each element vals = [v.strip(' \t\n\r') for v in vals] else: - outputVariables.append((key, expandedVal)) + if DEFAULT_VARS_SECTION_NAME == section.upper(): + defaultValues.append((key, expandedVal)) + else: + outputVariables.append((key, expandedVal)) pass pass # end if key pass # end for key,val @@ -230,7 +236,12 @@ def __processConfigFile(config, reserved = None, filename="UNKNOWN FILENAME"): vals = list(set(vals)) outVars.append((var, ','.join(vals))) - return unsetVariables, outVars, reservedValues + ConfigInfo = collections.namedtuple("ConfigInfo", + ["unsetVariables", + "outputVariables", + "reservedValues", + "defaultValues"]) + return ConfigInfo(unsetVariables, outVars, reservedValues, defaultValues) # def _trimColons(var):