def open(self, name, mode="<STR_LIT:r>", pwd=None):
if mode not in ("<STR_LIT:r>", "<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if not self.fp:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if self._filePassed:<EOL><INDENT>zef_file = self.fp<EOL><DEDENT>else:<EOL><INDENT>zef_file = open(self.filename, '<STR_LIT:rb>')<EOL><DEDENT>if isinstance(name, ZipInfo):<EOL><INDENT>zinfo = name<EOL><DEDENT>else:<EOL><INDENT>zinfo = self.getinfo(name)<EOL><DEDENT>zef_file.seek(zinfo.header_offset, <NUM_LIT:0>)<EOL>fheader = zef_file.read(sizeFileHeader)<EOL>if fheader[<NUM_LIT:0>:<NUM_LIT:4>] != stringFileHeader:<EOL><INDENT>raise BadZipfile("<STR_LIT>")<EOL><DEDENT>fheader = struct.unpack(structFileHeader, fheader)<EOL>fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])<EOL>if fheader[_FH_EXTRA_FIELD_LENGTH]:<EOL><INDENT>zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])<EOL><DEDENT>if fname != zinfo.orig_filename:<EOL><INDENT>raise BadZipfile('<STR_LIT>' % (<EOL>zinfo.orig_filename, fname))<EOL><DEDENT>is_encrypted = zinfo.flag_bits & <NUM_LIT><EOL>zd = None<EOL>if is_encrypted:<EOL><INDENT>if not pwd:<EOL><INDENT>pwd = self.pwd<EOL><DEDENT>if not pwd:<EOL><INDENT>raise RuntimeError("<STR_LIT>""<STR_LIT>" % name)<EOL><DEDENT>zd = _ZipDecrypter(pwd)<EOL>bytes = zef_file.read(<NUM_LIT:12>)<EOL>h = list(map(zd, bytes[<NUM_LIT:0>:<NUM_LIT:12>]))<EOL>if zinfo.flag_bits & <NUM_LIT>:<EOL><INDENT>check_byte = (zinfo._raw_time >> <NUM_LIT:8>) & <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>check_byte = (zinfo.CRC >> <NUM_LIT>) & <NUM_LIT><EOL><DEDENT>if ord(h[<NUM_LIT:11>]) != check_byte:<EOL><INDENT>raise RuntimeError("<STR_LIT>", name)<EOL><DEDENT><DEDENT>if zd is None:<EOL><INDENT>zef = ZipExtFile(zef_file, zinfo)<EOL><DEDENT>else:<EOL><INDENT>zef = ZipExtFile(zef_file, zinfo, zd)<EOL><DEDENT>if "<STR_LIT>" in mode:<EOL><INDENT>zef.set_univ_newlines(True)<EOL><DEDENT>return zef<EOL>
Return file-like object for 'name'.