<s> import traceback <EOL> from . logger import Logger <EOL> from . settings import Settings <EOL> class _ActionHistory : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def instance ( cls ) : <EOL> if not hasattr ( cls , "<STR_LIT>" ) : <EOL> cls . _instance = cls ( ) <EOL> return cls . _instance <EOL> def __init__ ( self ) : <EOL> self . reset ( ) <EOL> def reset ( self ) : <EOL> """<STR_LIT>""" <EOL> self . actions = [ ] <EOL> def add_action ( self , name , message , exception = None ) : <EOL> """<STR_LIT>""" <EOL> if not Settings ( ) . ready ( ) or Settings ( ) . get ( "<STR_LIT>" ) : <EOL> if exception : <EOL> message += "<STR_LIT>" + traceback . format_exc ( ) <EOL> Logger ( ) . error ( <EOL> "<STR_LIT>" % ( message , traceback . format_exc ( ) ) <EOL> ) <EOL> self . actions . append ( ( name , message ) ) <EOL> def is_starts_with ( self , string , values ) : <EOL> """<STR_LIT>""" <EOL> for e in values : <EOL> if string . startswith ( e ) : <EOL> return True <EOL> return False <EOL> def get_action ( self , include = None , exclude = None ) : <EOL> """<STR_LIT>""" <EOL> include = include or ( ) <EOL> exclude = exclude or ( ) <EOL> return [ <EOL> action [ <NUM_LIT:1> ] <EOL> for action in self . actions <EOL> if ( <EOL> ( <EOL> len ( include ) <= <NUM_LIT:0> or <EOL> self . is_starts_with ( action [ <NUM_LIT:0> ] , include ) <EOL> ) and ( <EOL> len ( exclude ) <= <NUM_LIT:0> or <EOL> not self . is_starts_with ( action [ <NUM_LIT:0> ] , exclude ) <EOL> ) <EOL> ) <EOL> ] <EOL> def ActionHistory ( ) : <EOL> return _ActionHistory . instance ( ) </s>
