<s> from urlparse import urlparse <EOL> from statsd import StatsClient <EOL> def parse_url ( url ) : <EOL> parsed = urlparse ( url ) <EOL> host = parsed . hostname or '<STR_LIT:localhost>' <EOL> port = parsed . port or <NUM_LIT> <EOL> prefix = parsed . path [ <NUM_LIT:1> : ] . replace ( '<STR_LIT:/>' , '<STR_LIT:.>' ) or '<STR_LIT>' <EOL> return ( host , port , prefix ) <EOL> def init_statsd ( config ) : <EOL> statsd_url = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> host , port , prefix = parse_url ( statsd_url ) <EOL> return StatsClient ( host , port , prefix = prefix ) </s>
