code: def _subst_vars(path, local_vars):
      
      def _replacer(matchobj):
          name = matchobj.group(1)
          if name in local_vars:
              return local_vars[name]
          elif name in os.environ:
              return os.environ[name]
          return matchobj.group(0)
      return _VAR_REPL.sub(_replacer, path)
docs: 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.