SCons, testing additional files to clean

SCons supports a list of files to be also deleted on "scons -c" (cleaning). Here is a code example how to check that a file is in the list.

Actually, it not the list, but an associative array. Keys are the targets, values are the lists.

# 'env' is the SCons environment
# 'node' is a SCons node for the target
# --
# Check that the target has a cleaning list
assert SCons.Environment.CleanTargets.has_key(node)
# Get the cleaning list
clist = SCons.Environment.CleanTargets[node]
# Create a list of nodes from the list of files
rej_node = env.arg2nodes(os.path.join('tmp', 'file.tex.rej'))
# Check that the cleaning list is as expected
assert clist == rej_node
Categories: consodoc

Updated: