<s> try : <EOL> from urllib import parse as urlparse <EOL> except ImportError : <EOL> import urlparse <EOL> def connect_message_queue ( name , url = None , maxsize = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if not url : <EOL> from pyspider . libs . multiprocessing_queue import Queue <EOL> return Queue ( maxsize = maxsize ) <EOL> parsed = urlparse . urlparse ( url ) <EOL> if parsed . scheme == '<STR_LIT>' : <EOL> from . rabbitmq import Queue <EOL> return Queue ( name , url , maxsize = maxsize ) <EOL> elif parsed . scheme == '<STR_LIT>' : <EOL> from . beanstalk import Queue <EOL> return Queue ( name , host = parsed . netloc , maxsize = maxsize ) <EOL> elif parsed . scheme == '<STR_LIT>' : <EOL> from . redis_queue import Queue <EOL> db = parsed . path . lstrip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) <EOL> try : <EOL> db = int ( db [ <NUM_LIT:0> ] ) <EOL> except : <EOL> db = <NUM_LIT:0> <EOL> password = parsed . password or None <EOL> return Queue ( name , parsed . hostname , parsed . port , db = db , maxsize = maxsize , password = password ) <EOL> else : <EOL> if url . startswith ( '<STR_LIT>' ) : <EOL> url = url [ len ( '<STR_LIT>' ) : ] <EOL> from . kombu_queue import Queue <EOL> return Queue ( name , url , maxsize = maxsize ) <EOL> raise Exception ( '<STR_LIT>' , url ) </s>
