<s> class KeyNotFound ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class KeyNotIncrementable ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class Stats ( object ) : <EOL> def set ( self , key , value ) : <EOL> if key not in self . _stats : <EOL> raise KeyNotFound ( key ) <EOL> self . _stats [ key ] = value <EOL> def get ( self , key ) : <EOL> if key not in self . _stats : <EOL> raise KeyNotFound ( key ) <EOL> return self . _stats [ key ] <EOL> def inc ( self , key , inc = <NUM_LIT:1> ) : <EOL> if key not in self . _stats : <EOL> raise KeyNotFound ( key ) <EOL> if not isinstance ( self . _stats [ key ] , int ) : <EOL> raise KeyNotIncrementable ( key ) <EOL> self . _stats [ key ] += inc <EOL> def dec ( self , key , inc = <NUM_LIT:1> ) : <EOL> if key not in self . _stats : <EOL> raise KeyNotFound ( key ) <EOL> if not isinstance ( self . _stats [ key ] , int ) : <EOL> raise KeyNotIncrementable ( key ) <EOL> self . _stats [ key ] -= inc </s>
