code: def add_doc(archive, topdir):
      write("Add help files to", archive)
      if archive.endswith(".tar") or ".tar." in archive:
          if archive.endswith(".Z"):
              raise Exception(
                  "tarfile module doesn't support old school compress so we can't add doc "
                  + archive
              )
          fmt = ""
          if archive.endswith(".gz") or archive.endswith(".tgz"):
              fmt = ":gz"
          elif archive.endswith(".bz2") or archive.endswith(".tbz2"):
              fmt = ":bz2"
          oldarchive = tarfile.open(archive)
          newarchive = tarfile.open(archive + "-", mode="w" + fmt)
          for mem in oldarchive.getmembers():
              newarchive.addfile(mem, oldarchive.extractfile(mem))
          oldarchive.close()
          for arcname, fname in help_walker(topdir):
              newarchive.add(fname, arcname)
          newarchive.close()
          os.rename(archive + "-", archive)
      elif archive.endswith(".zip"):
          ofile = zipfile.ZipFile(archive, "a", zipfile.ZIP_DEFLATED)
          for arcname, fname in help_walker(topdir):
              ofile.write(fname, arcname)
          ofile.close()
      else:
          raise Exception("Don't know what to do with " + archive)
  
imports: import os
  import sys
  import shlex
  import glob
  import re
  import time
  import zipfile
  import tarfile
  from distutils.command import build_ext, build, sdist
label_desc: Use image node_id 9 for calling a global function with example usage: add_doc(archive, topdir) without return types