def extract(zf, content, out_dir='<STR_LIT:.>'):
previous_header_offset = <NUM_LIT:0><EOL>compensation = Namespace(value=<NUM_LIT:2>**<NUM_LIT:32>, factor=<NUM_LIT:0>)<EOL>for i,member in enumerate(zf.infolist()):<EOL><INDENT>'''<STR_LIT>'''<EOL>if i == <NUM_LIT:0>:<EOL><INDENT>concat = member.header_offset<EOL><DEDENT>member.header_offset -= concat<EOL>if previous_header_offset > member.header_offset:<EOL><INDENT>compensation.factor += <NUM_LIT:1><EOL><DEDENT>previous_header_offset = member.header_offset<EOL>member.header_offset += compensation.value * compensation.factor<EOL>try:<EOL><INDENT>bio = io.BytesIO(zf.read(member.filename))<EOL><DEDENT>except zipfile.BadZipfile:<EOL><INDENT>with tf.NamedTemporaryFile(dir=out_dir, prefix="<STR_LIT>",<EOL>suffix="<STR_LIT>", delete=False) as fo:<EOL><INDENT>content.seek(<NUM_LIT:0>)<EOL>fo.write(content.read())<EOL><DEDENT>raise DownloadError("<STR_LIT>" % fo.name)<EOL><DEDENT>if not member.filename.endswith("<STR_LIT>"):<EOL><INDENT>try:<EOL><INDENT>gz = gzip.GzipFile(fileobj=bio, mode="<STR_LIT:rb>")<EOL>gz.read()<EOL>bio = gz<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>bio.seek(<NUM_LIT:0>)<EOL>f = os.path.join(out_dir, os.path.basename(member.filename))<EOL>with open(f, "<STR_LIT:wb>") as fo:<EOL><INDENT>fo.write(bio.read())<EOL><DEDENT><DEDENT>
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