#NEWLINE# def _find_best_vhost( self , target_name ) : #NEWLINE# #INDENT# 'Finds the best vhost for a target_name.\n\n        This does not upgrade a vhost to HTTPS... it only finds the most\n        appropriate vhost for the given target_name.\n\n        :returns: VHost or None\n\n        ' #NEWLINE# best_candidate = None #NEWLINE# best_points = 0 #NEWLINE# for vhost in self . vhosts : #NEWLINE# #INDENT# if ( vhost . modmacro is True ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# names = vhost . get_names ( ) #NEWLINE# if ( target_name in names ) : #NEWLINE# #INDENT# points = 3 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . included_in_wildcard ( names , target_name ) : #NEWLINE# #INDENT# points = 2 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if any ( ( ( addr . get_addr ( ) == target_name ) for addr in vhost . addrs ) ) : #NEWLINE# #INDENT# points = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if vhost . ssl : #NEWLINE# #INDENT# points += 3 #NEWLINE# #UNINDENT# if ( points > best_points ) : #NEWLINE# #INDENT# best_points = points #NEWLINE# best_candidate = vhost #NEWLINE# #UNINDENT# #UNINDENT# if ( best_candidate is None ) : #NEWLINE# #INDENT# vhosts = self . _non_default_vhosts ( ) #NEWLINE# reasonable_vhosts = [ vh for vh in vhosts if ( vh . modmacro is False ) ] #NEWLINE# if ( len ( reasonable_vhosts ) == 1 ) : #NEWLINE# #INDENT# best_candidate = reasonable_vhosts [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# return best_candidate