<s> """<STR_LIT>""" <EOL> from riak . datatypes . datatype import Datatype <EOL> from riak . datatypes import TYPES <EOL> class Counter ( Datatype ) : <EOL> """<STR_LIT>""" <EOL> type_name = '<STR_LIT>' <EOL> _type_error_msg = "<STR_LIT>" <EOL> def _post_init ( self ) : <EOL> self . _increment = <NUM_LIT:0> <EOL> def _default_value ( self ) : <EOL> return <NUM_LIT:0> <EOL> @ Datatype . modified . getter <EOL> def modified ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _increment is not <NUM_LIT:0> <EOL> def to_op ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _increment == <NUM_LIT:0> : <EOL> return ( '<STR_LIT>' , self . _increment ) <EOL> def increment ( self , amount = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _raise_if_badtype ( amount ) <EOL> self . _increment += amount <EOL> def decrement ( self , amount = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _raise_if_badtype ( amount ) <EOL> self . _increment -= amount <EOL> def _check_type ( self , new_value ) : <EOL> return ( isinstance ( new_value , int ) or <EOL> isinstance ( new_value , long ) ) <EOL> TYPES [ '<STR_LIT>' ] = Counter </s>
