On 12/16/2011 07:47 PM, Chris Evich wrote:
> Hrrrmmmm, git send-email didn't like my examples :S
>
> image_name = f16-64
> cdrom_unattended = images/${image_name}/ks.iso
> kernel = images/${image_name}/pxeboot/vmlinuz
> etc...
>
> I did some cursory testing and the patch seems basically functional.
> I'm not sure if there are hidden gotchas or how well it works across
> (already parsed) variants.
>
> Either way, I'm curious for feedback if others think this would be a
> handy feature.
I was looking into this, fine by me, as soon as I finish checking the
config file unification patches, I'll commit it. Would you document the
new feature?
Cheers,
Lucas
> On 12/16/2011 04:31 PM, Chris Evich wrote:
>> Allows use of $key or ${key} substitutions of backreferenced values.
>> This makes it convenient for using existing keys as the basis for
>> subsequent ones. For example:
>>
>> Signed-off-by: Chris Evich<[email protected]>
>> ---
>> client/common_lib/cartesian_config.py | 20 +++++++++++++-------
>> 1 files changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/client/common_lib/cartesian_config.py
>> b/client/common_lib/cartesian_config.py
>> index 62bc925..ccef74f 100755
>> --- a/client/common_lib/cartesian_config.py
>> +++ b/client/common_lib/cartesian_config.py
>> @@ -28,7 +28,7 @@ Cartesian configuration format file parser.
>> @copyright: Red Hat 2008-2011
>> """
>>
>> -import re, os, optparse, collections
>> +import re, os, optparse, collections, string
>>
>> class ParserError:
>> def __init__(self, msg, line=None, filename=None, linenum=None):
>> @@ -535,38 +535,44 @@ _reserved_keys = set(("name", "shortname", "dep"))
>>
>> def _op_set(d, key, value):
>> if key not in _reserved_keys:
>> - d[key] = value
>> + st = string.Template(value)
>> + d[key] = st.safe_substitute(d)
>>
>>
>> def _op_append(d, key, value):
>> if key not in _reserved_keys:
>> - d[key] = d.get(key, "") + value
>> + st = string.Template(value)
>> + d[key] = d.get(key, "") + st.safe_substitute(d)
>>
>>
>> def _op_prepend(d, key, value):
>> if key not in _reserved_keys:
>> - d[key] = value + d.get(key, "")
>> + st = string.Template(value)
>> + d[key] = st.safe_substitute(d) + d.get(key, "")
>>
>>
>> def _op_regex_set(d, exp, value):
>> exp = re.compile("%s$" % exp)
>> + st = string.Template(value)
>> for key in d:
>> if key not in _reserved_keys and exp.match(key):
>> - d[key] = value
>> + d[key] = st.safe_substitute(d)
>>
>>
>> def _op_regex_append(d, exp, value):
>> exp = re.compile("%s$" % exp)
>> + st = string.Template(value)
>> for key in d:
>> if key not in _reserved_keys and exp.match(key):
>> - d[key] += value
>> + d[key] += st.safe_substitute(d)
>>
>>
>> def _op_regex_prepend(d, exp, value):
>> exp = re.compile("%s$" % exp)
>> + st = string.Template(value)
>> for key in d:
>> if key not in _reserved_keys and exp.match(key):
>> - d[key] = value + d[key]
>> + d[key] = st.safe_substitute(d) + d[key]
>>
>>
>> def _op_regex_del(d, empty, exp):
>
>
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest