<s> class PID ( object ) : <EOL> __slots__ = ( '<STR_LIT>' , '<STR_LIT:port>' , '<STR_LIT:id>' ) <EOL> @ classmethod <EOL> def from_string ( cls , pid ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> id_ , ip_port = pid . split ( '<STR_LIT:@>' ) <EOL> ip , port = ip_port . split ( '<STR_LIT::>' ) <EOL> port = int ( port ) <EOL> except ValueError : <EOL> raise ValueError ( '<STR_LIT>' % pid ) <EOL> return cls ( ip , port , id_ ) <EOL> def __init__ ( self , ip , port , id_ ) : <EOL> """<STR_LIT>""" <EOL> self . ip = ip <EOL> self . port = port <EOL> self . id = id_ <EOL> def __hash__ ( self ) : <EOL> return hash ( ( self . ip , self . port , self . id ) ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , PID ) and ( <EOL> self . ip == other . ip and <EOL> self . port == other . port and <EOL> self . id == other . id <EOL> ) <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> def as_url ( self , endpoint = None ) : <EOL> url = '<STR_LIT>' % ( self . ip , self . port , self . id ) <EOL> if endpoint : <EOL> url += '<STR_LIT>' % endpoint <EOL> return url <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . id , self . ip , self . port ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . ip , self . port , self . id ) </s>
