def _subst_vars(path, local_vars):
def _replacer(matchobj):<EOL><INDENT>name = matchobj.group(<NUM_LIT:1>)<EOL>if name in local_vars:<EOL><INDENT>return local_vars[name]<EOL><DEDENT>elif name in os.environ:<EOL><INDENT>return os.environ[name]<EOL><DEDENT>return matchobj.group(<NUM_LIT:0>)<EOL><DEDENT>return _VAR_REPL.sub(_replacer, path)<EOL>
In the string `path`, replace tokens like {some.thing} with the
    corresponding value from the map `local_vars`.

    If there is no corresponding value, leave the token unchanged.