+ 1#============================================================================
+ 2#Name : escapeddict.py
+ 3#Part of : Helium
+ 4
+ 5#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ 6#All rights reserved.
+ 7#This component and the accompanying materials are made available
+ 8#under the terms of the License "Eclipse Public License v1.0"
+ 9#which accompanies this distribution, and is available
+10#at the URL "http://www.eclipse.org/legal/epl-v10.html".
+11#
+12#Initial Contributors:
+13#Nokia Corporation - initial contribution.
+14#
+15#Contributors:
+16#
+17#Description:
+18#===============================================================================
+19
+20""" This class enables developer to use ${xxx} pattern in their dict and
+21 get them replaced recursively.
+22"""
+23importre
+24importtypes
+25importUserDict
+26
+27
+
71""" Escape a string recursively.
+72
+73 :param input_string: the string to be escaped.
+74 :param config: a dictionnary containing the values to escape.
+75 :return: the escaped string.
+76 """
+77data=EscapedDict(config)
+78match=re.search(r'\${(?P<name>[._a-zA-Z0-9]+)}',input_string)
+79ifmatch!=None:
+80forproperty_nameinmatch.groups():
+81property_value=data[property_name]
+82property_value=re.sub(r'\\',r'\\\\',property_value)
+83input_string=re.sub('\${'+property_name+'}',property_value,input_string)
+84returninput_string
+