<s> import logging <EOL> import re <EOL> from rules import rule <EOL> class LogUrl ( rule . Rule ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url , stop = False ) : <EOL> r"""<STR_LIT>""" <EOL> self . _url_re = re . compile ( url ) <EOL> self . _stop = stop <EOL> def IsType ( self , rule_type_name ) : <EOL> """<STR_LIT>""" <EOL> return rule_type_name == '<STR_LIT>' <EOL> def ApplyRule ( self , return_value , request , response ) : <EOL> """<STR_LIT>""" <EOL> del response <EOL> url = '<STR_LIT>' % ( request . host , request . full_path ) <EOL> if not self . _url_re . match ( url ) : <EOL> return False , return_value <EOL> logging . debug ( '<STR_LIT>' , url ) <EOL> return self . _stop , True <EOL> def __str__ ( self ) : <EOL> return _ToString ( self , ( '<STR_LIT:url>' , self . _url_re . pattern ) , <EOL> None if self . _stop else ( '<STR_LIT>' , False ) ) <EOL> def __repr__ ( self ) : <EOL> return str ( self ) <EOL> def _ToString ( obj , * items ) : <EOL> pkg = ( obj . __module__ [ : obj . __module__ . rfind ( '<STR_LIT:.>' ) + <NUM_LIT:1> ] <EOL> if '<STR_LIT:.>' in obj . __module__ else '<STR_LIT>' ) <EOL> clname = obj . __class__ . __name__ <EOL> args = [ ( '<STR_LIT>' % item if isinstance ( item [ <NUM_LIT:1> ] , basestring ) <EOL> else '<STR_LIT>' % item ) for item in items if item ] <EOL> return '<STR_LIT>' % ( pkg , clname , '<STR_LIT:U+002CU+0020>' . join ( args ) ) </s>
