[Scons-dev] Subst API...

Kenny, Jason L jason.l.kenny at intel.com
Mon Oct 1 15:38:45 EDT 2012



Hi guys,

I starting to try to get a set of small patches to the current SCons code to deal with small items in the Subst and "macros" that SCons provides.

As I was going over the code I notice a number of things.. I want to ask about two of the items I found.

One of the is the functions below... it seems that it been hacked a lot without an overall looking at the changes
------
def _concat_ixes(prefix, list, suffix, env):
"""
Creates a new list from 'list' by concatenating the 'prefix' and
'suffix' arguments onto each element of the list. A trailing space
on 'prefix' or leading space on 'suffix' will cause them to be put
into separate list elements rather than being concatenated.
"""

result = []

# ensure that prefix and suffix are strings
prefix = str(env.subst(prefix, SCons.Subst.SUBST_RAW))
suffix = str(env.subst(suffix, SCons.Subst.SUBST_RAW))

for x in list:
if isinstance(x, SCons.Node.FS.File):
result.append(x)
continue
x = str(x)
if x:

if prefix:
if prefix[-1] == ' ':
result.append(prefix[:-1])
elif x[:len(prefix)] != prefix:
x = prefix + x

result.append(x)

if suffix:
if suffix[0] == ' ':
result.append(suffix[1:])
elif x[-len(suffix):] != suffix:
result[-1] = result[-1]+suffix

return result


I thinks this is a better replacements.. but I was wonder if there was any reasons code above is really needed in the way it is...

def _concat_ixes(prefix, list, suffix, env):
"""
Redo of the same logic in SCons...
The functions adds a prefix and or suffix to the string value
equals of the list
"""

result = []

# ensure that prefix and suffix are strings
# also remove any extra white space on the ends
prefix = str(env.subst(prefix, SCons.Subst.SUBST_RAW)).strip()
suffix = str(env.subst(suffix, SCons.Subst.SUBST_RAW)).strip()


# go over the list and add values as needed
for x in list:
if x:
#make sure items is a string
x = str(x)
# do we start with prefix?
if not x.startswith(prefix):
#if not add prefix
x = prefix + x

# do we end with suffix?
if not x.endswith(suffix):
#if not add suffix
x += suffix

result.append(x)

return result


The second question is

Does anyone have issue with CmdStringHolder class changing the use of collection.UserString parent to str?

Thanks
Jason


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/scons-dev/attachments/20121001/15b86836/attachment.htm>


More information about the Scons-dev mailing list