<s> import logging <EOL> import statsd <EOL> from . import compat <EOL> class Client ( object ) : <EOL> '''<STR_LIT>''' <EOL> name = None <EOL> connection = None <EOL> def __init__ ( self , name , connection = None ) : <EOL> self . name = self . _get_name ( name ) <EOL> if not connection : <EOL> connection = statsd . Connection ( ) <EOL> self . connection = connection <EOL> self . logger = logging . getLogger ( <EOL> '<STR_LIT>' % ( __name__ , self . __class__ . __name__ ) ) <EOL> @ classmethod <EOL> def _get_name ( cls , * name_parts ) : <EOL> name_parts = [ compat . to_str ( x ) for x in name_parts if x ] <EOL> return '<STR_LIT:.>' . join ( name_parts ) <EOL> def get_client ( self , name = None , class_ = None ) : <EOL> '''<STR_LIT>''' <EOL> name = self . _get_name ( self . name , name ) <EOL> if not class_ : <EOL> class_ = self . __class__ <EOL> return class_ ( <EOL> name = name , <EOL> connection = self . connection , <EOL> ) <EOL> def get_average ( self , name = None ) : <EOL> '''<STR_LIT>''' <EOL> return self . get_client ( name = name , class_ = statsd . Average ) <EOL> def get_counter ( self , name = None ) : <EOL> '''<STR_LIT>''' <EOL> return self . get_client ( name = name , class_ = statsd . Counter ) <EOL> def get_gauge ( self , name = None ) : <EOL> '''<STR_LIT>''' <EOL> return self . get_client ( name = name , class_ = statsd . Gauge ) <EOL> def get_raw ( self , name = None ) : <EOL> '''<STR_LIT>''' <EOL> return self . get_client ( name = name , class_ = statsd . Raw ) <EOL> def get_timer ( self , name = None ) : <EOL> '''<STR_LIT>''' <EOL> return self . get_client ( name = name , class_ = statsd . Timer ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> self . __class__ . __name__ , <EOL> self . name , <EOL> self . connection , <EOL> ) <EOL> def _send ( self , data ) : <EOL> return self . connection . send ( data ) </s>
