<s> """<STR_LIT>""" <EOL> from circuits . six import text_type , u , PY3 <EOL> from . utils import parsemsg <EOL> class Error ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class Message ( object ) : <EOL> def __init__ ( self , command , * args , ** kwargs ) : <EOL> for arg in args [ : - <NUM_LIT:1> ] : <EOL> if u ( "<STR_LIT:U+0020>" ) in arg : <EOL> raise Error ( "<STR_LIT>" ) <EOL> self . command = command <EOL> self . args = list ( filter ( lambda x : x is not None , list ( args ) ) ) <EOL> self . prefix = text_type ( kwargs [ "<STR_LIT>" ] ) if "<STR_LIT>" in kwargs else None <EOL> self . encoding = kwargs . get ( "<STR_LIT>" , "<STR_LIT:utf-8>" ) <EOL> self . add_nick = kwargs . get ( "<STR_LIT>" , False ) <EOL> @ staticmethod <EOL> def from_string ( s ) : <EOL> if len ( s ) > <NUM_LIT> : <EOL> raise Error ( "<STR_LIT>" ) <EOL> prefix , command , args = parsemsg ( s ) <EOL> return Message ( command , * args , prefix = prefix ) <EOL> def __str__ ( self ) : <EOL> return self . __unicode__ ( ) if PY3 else self . __bytes__ ( ) <EOL> def __bytes__ ( self ) : <EOL> return text_type ( self ) . encode ( self . encoding ) <EOL> def __unicode__ ( self ) : <EOL> args = self . args [ : ] <EOL> for arg in args [ : - <NUM_LIT:1> ] : <EOL> if arg is not None and u ( "<STR_LIT:U+0020>" ) in arg : <EOL> raise Error ( "<STR_LIT>" ) <EOL> if len ( args ) > <NUM_LIT:0> and u ( "<STR_LIT:U+0020>" ) in args [ - <NUM_LIT:1> ] and args [ - <NUM_LIT:1> ] [ <NUM_LIT:0> ] != u ( "<STR_LIT::>" ) : <EOL> args [ - <NUM_LIT:1> ] = u ( "<STR_LIT>" ) . format ( args [ - <NUM_LIT:1> ] ) <EOL> return u ( "<STR_LIT>" ) . format ( <EOL> prefix = ( <EOL> u ( "<STR_LIT>" ) . format ( self . prefix ) <EOL> if self . prefix is not None <EOL> else u ( "<STR_LIT>" ) <EOL> ) , <EOL> command = text_type ( self . command ) , <EOL> args = u ( "<STR_LIT:U+0020>" ) . join ( args ) <EOL> ) <EOL> def __repr__ ( self ) : <EOL> return repr ( text_type ( self ) [ : - <NUM_LIT:2> ] ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , Message ) and self . prefix == other . prefix and self . command == other . command and self . args == other . args </s>
