def guess_zip_filename(zf):
 files = zf.namelist()
 if (len(files) == 1):
  return files[0]
 else:
  for e in files:
   if (posixpath.splitext(e)[0].lower() == 'hosts'):
    return e
 raise FileNotFoundError('No hosts file found in zip')

def guess_zip_filename ( zf ) : files = zf . namelist ( ) if ( len ( files ) == 1 ) : return files [ 0 ] else : for e in files : if ( posixpath . splitext ( e ) [ 0 ] . lower ( ) == 'hosts' ) : return e raise FileNotFoundError ( 'No hosts file found in zip' )
guess which file to use inside a zip file .