code: def expand(string, vars, local_vars={}):
      """Expand a string containing $vars as Ninja would.
  
      Note: doesn't handle the full Ninja variable syntax, but it's enough
      to make configure.py's use of it work.
      """
  
      def exp(m):
          var = m.group(1)
          if var == "$":
              return "$"
          return local_vars.get(var, vars.get(var, ""))
  
      return re.sub(r"\$(\$|\w*)", exp, string)
  
imports: import re
  import textwrap
label_desc: Use image node_id 4 for calling a global function with example usage: expand(string, vars, local_vars) and returns: re, local_vars, str