<s> """<STR_LIT>""" <EOL> from urlparse import urlparse <EOL> from spyder . core . frontier import PROTOCOLS_DEFAULT_PORT <EOL> class HostBasedQueueAssignment ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dnscache ) : <EOL> """<STR_LIT>""" <EOL> self . _dns_cache = dnscache <EOL> def get_identifier ( self , url ) : <EOL> """<STR_LIT>""" <EOL> parsed_url = urlparse ( url ) <EOL> return parsed_url . hostname <EOL> class IpBasedQueueAssignment ( HostBasedQueueAssignment ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dnscache ) : <EOL> """<STR_LIT>""" <EOL> HostBasedQueueAssignment . __init__ ( self , dnscache ) <EOL> def get_identifier ( self , url ) : <EOL> """<STR_LIT>""" <EOL> parsed_url = urlparse ( url ) <EOL> port = parsed_url . port <EOL> if not port : <EOL> port = PROTOCOLS_DEFAULT_PORT [ parsed_url . scheme ] <EOL> ( ip , port ) = self . _dns_cache [ "<STR_LIT>" % ( parsed_url . hostname , port ) ] <EOL> return "<STR_LIT:%s>" % ( ip , ) </s>
