'Replace values with variable names, and store the original values
This replaces all of the variable substitutions with usable variable
names, and stores the original values in the dictionary provided. If
there are naming conflicts, it adds underscores to the variable name.
Ex:
$.shuffle( BLAH )  =>  __shuffle_BLAH_'

@staticmethod
def var_replace_builder(var_dict):

    def replace_with_var(match):
        content = match.group(1)
        var_name = re.sub('\\W', '_', content)
        while ((var_name in var_dict) and (var_dict[var_name] != content)):
            var_name += '_'
        var_dict[var_name] = content
        return ('%%(%s)s' % var_name)
    return replace_with_var
