def extract_wininst_cfg(dist_filename):
f = open(dist_filename,'<STR_LIT:rb>')<EOL>try:<EOL><INDENT>endrec = zipfile._EndRecData(f)<EOL>if endrec is None:<EOL><INDENT>return None<EOL><DEDENT>prepended = (endrec[<NUM_LIT:9>] - endrec[<NUM_LIT:5>]) - endrec[<NUM_LIT:6>]<EOL>if prepended < <NUM_LIT:12>:  <EOL><INDENT>return None<EOL><DEDENT>f.seek(prepended-<NUM_LIT:12>)<EOL>import struct, io, configparser<EOL>tag, cfglen, bmlen = struct.unpack("<STR_LIT>",f.read(<NUM_LIT:12>))<EOL>if tag not in (<NUM_LIT>, <NUM_LIT>):<EOL><INDENT>return None     <EOL><DEDENT>f.seek(prepended-(<NUM_LIT:12>+cfglen))<EOL>cfg = configparser.RawConfigParser({'<STR_LIT:version>':'<STR_LIT>','<STR_LIT>':'<STR_LIT>'})<EOL>try:<EOL><INDENT>part = f.read(cfglen)<EOL>if sys.version_info >= (<NUM_LIT:2>,<NUM_LIT:6>):<EOL><INDENT>null_byte = bytes([<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>null_byte = chr(<NUM_LIT:0>)<EOL><DEDENT>config = part.split(null_byte, <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>config = config.decode('<STR_LIT:ascii>')<EOL>cfg.readfp(io.StringIO(config))<EOL><DEDENT>except configparser.Error:<EOL><INDENT>return None<EOL><DEDENT>if not cfg.has_section('<STR_LIT>') or not cfg.has_section('<STR_LIT>'):<EOL><INDENT>return None<EOL><DEDENT>return cfg<EOL><DEDENT>finally:<EOL><INDENT>f.close()<EOL><DEDENT>
Extract configuration data from a bdist_wininst .exe

    Returns a ConfigParser.RawConfigParser, or None