<s> """<STR_LIT>""" <EOL> try : <EOL> from urllib import quote <EOL> except ImportError : <EOL> from urllib . request import quote <EOL> import re <EOL> def makemap ( query ) : <EOL> querywords = [ ] <EOL> args = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> for word in query . split ( "<STR_LIT:U+0020>" ) : <EOL> if '<STR_LIT:=>' in word : <EOL> opt , val = word . split ( "<STR_LIT:=>" ) <EOL> args [ opt ] = val <EOL> else : <EOL> querywords . append ( word ) <EOL> query = quote ( "<STR_LIT:U+0020>" . join ( querywords ) . encode ( "<STR_LIT:utf8>" ) ) <EOL> url = "<STR_LIT>" <EOL> url = url . format ( query , args [ "<STR_LIT>" ] ) <EOL> if "<STR_LIT>" in args : <EOL> url += "<STR_LIT>" . format ( args [ "<STR_LIT>" ] ) <EOL> return url <EOL> def on_message ( msg , server ) : <EOL> text = msg . get ( "<STR_LIT:text>" , "<STR_LIT>" ) <EOL> match = re . findall ( r"<STR_LIT>" , text ) <EOL> if not match : <EOL> return <EOL> return makemap ( match [ <NUM_LIT:0> ] ) </s>
