code: def _do_subst(node, subs):
      
      contents = node.get_text_contents()
      if subs:
          for (k, val) in subs:
              contents = re.sub(k, val, contents)
  
      if 'b' in TEXTFILE_FILE_WRITE_MODE:
          try:
              contents = bytearray(contents, 'utf-8')
          except UnicodeDecodeError:
              # contents is already utf-8 encoded python 2 str i.e. a byte array
              contents = bytearray(contents)
  
      return contents
docs: Fetch the node contents and replace all instances of the keys with
      their values.  For example, if subs is
          {'%VERSION%': '1.2345', '%BASE%': 'MyProg', '%prefix%': '/bin'},
      then all instances of %VERSION% in the file will be replaced with
      1.2345 and so forth.