[openstack-dev] [fuel] FF Exception request for Templates for Networking feature
Aleksey Kasatkin
akasatkin at mirantis.com
Tue Jul 28 15:40:20 UTC 2015
AFAIU, string.Template doesn't help.
This seems to be helpful:
import re
def interp(string, params):
for item in re.findall(r'#\{([^}]*)\}', string):
string = string.replace('#{%s}' % item, str(eval(item, {}, params)))
return string
Evgeniy, do you know some better options for this?
Aleksey Kasatkin
On Tue, Jul 28, 2015 at 1:12 PM, Sergey Vasilenko <svasilenko at mirantis.com>
wrote:
> If we need only substitution, probably it's better to use standard
>> templating
>> in python [1], there is a way to redefine tokens, so you will be able to
>> use
>> <% %> syntax if you want to.
>>
>> [1] https://docs.python.org/2.6/library/string.html#template-strings
>> <https://docs.python.org/dev/library/string.html#template-strings>
>> [2] http://pymotw.com/2/string/#advanced-templates
>>
>
> I think it's a better solution for this issue.
>
> /sv
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150728/44cb7ad7/attachment.html>
More information about the OpenStack-dev
mailing list