docs: def extract(zf, content, out_dir='.'):
      '''
      Extracting a Java 1.6 XNAT ZIP archive in Python.
  
      :param zf: ZipFile object
      :type zf: zipfile.ZipFile
      :param out_dir: Output directory
      :type out_dir: str
      '''
      previous_header_offset = 0
      compensation = Namespace(value=2**32, factor=0)
      for i,member in enumerate(zf.infolist()):
          '''
          Right... so when Java 1.6 produces a Zip filesystem that exceeds 2^32
          bytes, the Central Directory local file header offsets after the 2^32 
          byte appear to overflow. The Python zipfile module then adds any 
          unexpected bytes to each header offset thereafter. This attempts to fix 
          that. My guess is that this comment might make perfect sense now, but 
          will make aboslutely no sense in about a year.
          '''
          # undo concat padding added from zipfile.py:819
          if i == 0:
              concat = member.header_offset
          member.header_offset -= concat
          # if a header offset moves backward, add 2^32 bytes * factor
          if previous_header_offset > member.header_offset:
              compensation.factor += 1
          previous_header_offset = member.header_offset
          member.header_offset += compensation.value * compensation.factor
          # read the archive member into a bytes file-like object
          try:
              bio = io.BytesIO(zf.read(member.filename))
          except zipfile.BadZipfile:
              with tf.NamedTemporaryFile(dir=out_dir, prefix="xnat",
                                     suffix=".zip", delete=False) as fo:
                  content.seek(0)
                  fo.write(content.read())
              raise DownloadError("bad zip file, written to %s" % fo.name)
          # xnat archives may contain files that are gzipped without the .gz
          if not member.filename.endswith(".gz"):
              try:
                  gz = gzip.GzipFile(fileobj=bio, mode="rb")
                  gz.read()
                  bio = gz
              except IOError:
                  pass
          # write the file out to the filesystem
          bio.seek(0)
          f = os.path.join(out_dir, os.path.basename(member.filename))
          with open(f, "wb") as fo:
              fo.write(bio.read())