#NEWLINE# def _parse_hosts( self ) : #NEWLINE# #INDENT# etc_path = '/etc/hosts' #NEWLINE# if ( 'WINDIR' in os . environ ) : #NEWLINE# #INDENT# etc_path = ( os . environ [ 'WINDIR' ] + '/system32/drivers/etc/hosts' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# with open ( etc_path , 'rb' ) as f : #NEWLINE# #INDENT# for line in f . readlines ( ) : #NEWLINE# #INDENT# line = line . strip ( ) #NEWLINE# parts = line . split ( ) #NEWLINE# if ( len ( parts ) >= 2 ) : #NEWLINE# #INDENT# ip = parts [ 0 ] #NEWLINE# if common . is_ip ( ip ) : #NEWLINE# #INDENT# for i in range ( 1 , len ( parts ) ) : #NEWLINE# #INDENT# hostname = parts [ i ] #NEWLINE# if hostname : #NEWLINE# #INDENT# self . _hosts [ hostname ] = ip #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except IOError : #NEWLINE# #INDENT# self . _hosts [ 'localhost' ] = '127.0.0.1'