<s> """<STR_LIT>""" <EOL> import sys <EOL> import cmd <EOL> from pychievements import tracker , Achievement , icons <EOL> from pychievements . signals import receiver , goal_achieved , highest_level_achieved <EOL> from pychievements . cli import print_goal , print_goals_for_tracked <EOL> class TheLister ( Achievement ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> category = '<STR_LIT>' <EOL> keywords = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> goals = ( <EOL> { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:15> , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : icons . star , <EOL> '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> ) <EOL> tracker . register ( TheLister ) <EOL> class TheCreator ( Achievement ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> category = '<STR_LIT>' <EOL> keywords = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> goals = ( <EOL> { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . unicodeCheck , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . unicodeCheckBox , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:15> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : icons . star , '<STR_LIT:description>' : '<STR_LIT>' } , <EOL> ) <EOL> def evaluate ( self , old_objects , new_objects , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _current += new_objects - old_objects <EOL> return self . achieved <EOL> tracker . register ( TheCreator ) <EOL> @ receiver ( goal_achieved ) <EOL> def new_goal ( tracked_id , achievement , goals , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> for g in goals : <EOL> print_goal ( g , True ) <EOL> @ receiver ( highest_level_achieved ) <EOL> def check_if_all_completed ( tracked_id , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> unachieved = [ ] <EOL> for a in tracker . achievements ( ) : <EOL> unachieved += tracker . unachieved ( tracked_id , a ) <EOL> if not unachieved : <EOL> print ( '<STR_LIT>' ) <EOL> class MyCLIProgram ( cmd . Cmd ) : <EOL> """<STR_LIT>""" <EOL> intro = '<STR_LIT>' <EOL> prompt = '<STR_LIT>' <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> cmd . Cmd . __init__ ( self , * args , ** kwargs ) <EOL> self . _objects = [ ] <EOL> def do_ls ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> for _ in self . _objects : <EOL> print ( _ ) <EOL> tracker . increment ( '<STR_LIT>' , TheLister ) <EOL> def do_create ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> old = len ( self . _objects ) <EOL> self . _objects += arg . split ( ) <EOL> tracker . evaluate ( '<STR_LIT>' , TheCreator , old , len ( self . _objects ) ) <EOL> def do_remove ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> for o in arg . split ( ) : <EOL> if o in self . _objects : <EOL> self . _objects . remove ( o ) <EOL> def do_achievements ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> showall = arg . lower ( ) == '<STR_LIT:all>' <EOL> current = arg . lower ( ) == '<STR_LIT>' <EOL> print ( '<STR_LIT>' ) <EOL> print_goals_for_tracked ( '<STR_LIT>' , achieved = True , unachieved = showall , only_current = current , <EOL> level = True ) <EOL> def do_exit ( self , arg ) : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def do_EOF ( self , arg ) : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> MyCLIProgram ( ) . cmdloop ( ) </s>
