class_docstr: Parse HOCON files: https://github.com/typesafehub/config/blob/master/HOCON.md
class_docstr_tok: ["Parse","HOCON","files",":","https",":","\/\/github.com\/typesafehub\/config\/blob\/master\/HOCON.md"]
code: def _do_substitute(
      cls, substitution, resolved_value, is_optional_resolved=True
  ):
      unresolved = False
      new_substitutions = []
      if isinstance(resolved_value, ConfigValues):
          resolved_value = resolved_value.transform()
      if isinstance(resolved_value, ConfigValues):
          unresolved = True
          result = resolved_value
      else:
          # replace token by substitution
          config_values = substitution.parent
          # if it is a string, then add the extra ws that was present in the original string after the substitution
          formatted_resolved_value = (
              resolved_value
              if resolved_value is None
              or isinstance(resolved_value, (dict, list))
              or substitution.index == len(config_values.tokens) - 1
              else (str(resolved_value) + substitution.ws)
          )
          # use a deepcopy of resolved_value to avoid mutation
          config_values.put(
              substitution.index,
              copy.deepcopy(formatted_resolved_value),
          )
          transformation = config_values.transform()
          result = (
              config_values.overriden_value
              if transformation is None and not is_optional_resolved
              else transformation
          )
  
          if (
              result is None
              and config_values.key in config_values.parent
          ):
              del config_values.parent[config_values.key]
          else:
              config_values.parent[config_values.key] = result
              s = cls._find_substitutions(result)
              if s:
                  new_substitutions = s
                  unresolved = True
  
      return (unresolved, new_substitutions, result)
  
imports: import itertools
  import re
  import os
  import socket
  import contextlib
  import codecs
  from datetime import timedelta
  from pyparsing import Forward, Keyword, QuotedString, Word, Literal, Suppress, Regex, Optional, SkipTo, ZeroOrMore, Group, lineno, col, TokenConverter, replaceWith, alphanums, alphas8bit, ParseSyntaxException, StringEnd
  from pyparsing import ParserElement
  from .config_tree import ConfigTree, ConfigSubstitution, ConfigList, ConfigValues, ConfigUnquotedString, ConfigInclude, NoneValue, ConfigQuotedString
  from .exceptions import ConfigSubstitutionException, ConfigMissingException, ConfigException
  import logging
  import copy
label_desc: Use image node_id 6 for calling the ConfigParser obj's underlying member method code with example usage: obj._do_substitute(cls, substitution, resolved_value, is_optional_resolved) and returns: unresolved,  new_substitutions,  result