(exe_filename)
return prefixes
Get exe->egg path translations for a given .exe file
Get exe->egg path translations for a given .exe file
Get exe - > egg path translations for a given . exe file
def get_exe_prefixes(exe_filename):
    """Get exe->egg path translations for a given .exe file"""

    prefixes = [
        ('PURELIB/', ''),
        ('PLATLIB/pywin32_system32', ''),
        ('PLATLIB/', ''),
        ('SCRIPTS/', 'EGG-INFO/scripts/'),
        ('DATA/lib/site-packages', ''),
    ]
    z = zipfile.ZipFile(exe_filename)
    try:
        for info in z.infolist():
            name = info.filename
            parts = name.split('/')
            if len(parts) == 3 and parts[2] == 'PKG-INFO':
                if parts[1].endswith('.egg-info'):
                    prefixes.insert(0, ('/'.join(parts[:2]), 'EGG-INFO/'))
                    break
            if len(parts) != 2 or not name.endswith('.pth'):
                continue
            if name.endswith('-nspkg.pth'):
                continue
            if parts[0].upper() in ('PURELIB', 'PLATLIB'):
                contents = z.read(name)
                if six.PY3:
                    contents = contents.decode()
                for pth in yield_lines(contents):
                    pth = pth.strip().replace('\\', '/')
                    if not pth.startswith('import'):
                        prefixes.append((('%s/%s/' % (parts[0], pth)), ''))
    finally:
        z.close()
    prefixes = [(x.lower(), y) for x, y in prefixes]
    prefixes.sort()
    prefixes.reverse()
    return prefixes
def get_exe_prefixes ( exe_filename ) : prefixes = [ ( 'PURELIB/' , '' ) , ( 'PLATLIB/pywin32_system32' , '' ) , ( 'PLATLIB/' , '' ) , ( 'SCRIPTS/' , 'EGG-INFO/scripts/' ) , ( 'DATA/lib/site-packages' , '' ) , ] z = zipfile . ZipFile ( exe_filename ) try : for info in z . infolist ( ) : name = info . filename parts = name . split ( '/' ) if len ( parts ) == 3 and parts [ 2 ] == 'PKG-INFO' : if parts [ 1 ] . endswith ( '.egg-info' ) : prefixes . insert ( 0 , ( '/' . join ( parts [ : 2 ] ) , 'EGG-INFO/' ) ) break if len ( parts ) != 2 or not name . endswith ( '.pth' ) : continue if name . endswith ( '-nspkg.pth' ) : continue if parts [ 0 ] . upper ( ) in ( 'PURELIB' , 'PLATLIB' ) : contents = z . read ( name ) if six . PY3 : contents = contents . decode ( ) for pth in yield_lines ( contents ) : pth = pth . strip ( ) . replace ( '\\' , '/' ) if not pth . startswith ( 'import' ) : prefixes . append ( ( ( '%s/%s/' % ( parts [ 0 ] , pth ) ) , '' ) ) finally : z . close ( ) prefixes = [ ( x . lower ( ) , y ) for x , y in prefixes ] prefixes . sort ( ) prefixes . reverse ( ) return prefixes