docs: def copy_dir(source, dest, vars, verbosity=1, simulate=False, indent=0,
               sub_vars=True, interactive=False, overwrite=True,
               template_renderer=None, out_=sys.stdout):
      """
      Copies the ``source`` directory to the ``dest`` directory.
  
      ``vars``: A dictionary of variables to use in any substitutions.
  
      ``verbosity``: Higher numbers will show more about what is happening.
  
      ``simulate``: If true, then don't actually *do* anything.
  
      ``indent``: Indent any messages by this amount.
  
      ``sub_vars``: If true, variables in ``_tmpl`` files and ``+var+``
      in filenames will be substituted.
  
      ``overwrite``: If false, then don't ever overwrite anything.
  
      ``interactive``: If you are overwriting a file and interactive is
      true, then ask before overwriting.
  
      ``template_renderer``: This is a function for rendering templates (if you
      don't want to use string.Template).  It should have the signature
      ``template_renderer(content_as_string, vars_as_dict,
      filename=filename)``.
      """
      def out(msg):
          out_.write(msg)
          out_.write('\n')
          out_.flush()
          # This allows you to use a leading +dot+ in filenames which would
      # otherwise be skipped because leading dots make the file hidden:
      vars.setdefault('dot', '.')
      vars.setdefault('plus', '+')
      use_pkg_resources = isinstance(source, tuple)
      if use_pkg_resources:
          names = sorted(pkg_resources.resource_listdir(source[0], source[1]))
      else:
          names = sorted(os.listdir(source))
      pad = ' '*(indent*2)
      if not os.path.exists(dest):
          if verbosity >= 1:
              out('%sCreating %s/' % (pad, dest))
          if not simulate:
              makedirs(dest, verbosity=verbosity, pad=pad)
      elif verbosity >= 2:
          out('%sDirectory %s exists' % (pad, dest))
      for name in names:
          if use_pkg_resources:
              full = '/'.join([source[1], name])
          else:
              full = os.path.join(source, name)
          reason = should_skip_file(name)
          if reason:
              if verbosity >= 2:
                  reason = pad + reason % {'filename': full}
                  out(reason)
              continue # pragma: no cover
          if sub_vars:
              dest_full = os.path.join(dest, substitute_filename(name, vars))
          sub_file = False
          if dest_full.endswith('_tmpl'):
              dest_full = dest_full[:-5]
              sub_file = sub_vars
          if use_pkg_resources and pkg_resources.resource_isdir(source[0], full):
              if verbosity:
                  out('%sRecursing into %s' % (pad, os.path.basename(full)))
              copy_dir((source[0], full), dest_full, vars, verbosity, simulate,
                  indent=indent+1,
                  sub_vars=sub_vars, interactive=interactive,
                  template_renderer=template_renderer, out_=out_)
              continue
          elif not use_pkg_resources and os.path.isdir(full):
              if verbosity:
                  out('%sRecursing into %s' % (pad, os.path.basename(full)))
              copy_dir(full, dest_full, vars, verbosity, simulate,
                  indent=indent+1,
                  sub_vars=sub_vars, interactive=interactive,
                  template_renderer=template_renderer, out_=out_)
              continue
          elif use_pkg_resources:
              content = pkg_resources.resource_string(source[0], full)
          else:
              f = open(full, 'rb')
              content = f.read()
              f.close()
          if sub_file:
              try:
                  content = substitute_content(
                      content, vars, filename=full,
                      template_renderer=template_renderer
                  )
              except SkipTemplate:
                  continue # pragma: no cover
              if content is None:
                  continue  # pragma: no cover
          already_exists = os.path.exists(dest_full)
          if already_exists:
              f = open(dest_full, 'rb')
              old_content = f.read()
              f.close()
              if old_content == content:
                  if verbosity:
                      out('%s%s already exists (same content)' %
                          (pad, dest_full))
                  continue # pragma: no cover
              if interactive:
                  if not query_interactive(
                      native_(full, fsenc), native_(dest_full, fsenc),
                      native_(content, fsenc), native_(old_content, fsenc),
                      simulate=simulate, out_=out_):
                      continue
              elif not overwrite:
                  continue # pragma: no cover
          if verbosity and use_pkg_resources:
              out('%sCopying %s to %s' % (pad, full, dest_full))
          elif verbosity:
              out(
                  '%sCopying %s to %s' % (pad, os.path.basename(full),
                                          dest_full))
          if not simulate:
              f = open(dest_full, 'wb')
              f.write(content)
              f.close()