<s> from operator import attrgetter <EOL> def projectAncestors ( target_project , project_pool , ancestors ) : <EOL> if target_project . Parent : <EOL> ancestors . append ( target_project . Parent ) <EOL> projectAncestors ( target_project . Parent , project_pool , ancestors ) <EOL> return reversed ( ancestors ) <EOL> def projeny ( target_project , project_pool , lineage , level ) : <EOL> """<STR_LIT>""" <EOL> lineage [ target_project ] = { } <EOL> child_projects = [ proj for proj in project_pool <EOL> if proj . Parent <EOL> and proj . Parent . ref == target_project . ref <EOL> ] <EOL> for child in child_projects : <EOL> projeny ( child , project_pool , lineage [ target_project ] , level + <NUM_LIT:1> ) <EOL> def flatten ( target_dict , sort_attr , list_o_things ) : <EOL> """<STR_LIT>""" <EOL> for key in sorted ( target_dict . keys ( ) , key = attrgetter ( sort_attr ) ) : <EOL> list_o_things . append ( getattr ( key , sort_attr ) ) <EOL> value = target_dict [ key ] <EOL> if isinstance ( value , dict ) : <EOL> flatten ( value , sort_attr , list_o_things ) <EOL> return list_o_things <EOL> def projectDescendants ( target_project , project_pool ) : <EOL> descendents = { } <EOL> projeny ( target_project , project_pool , descendents , <NUM_LIT:1> ) <EOL> return flatten ( descendents , '<STR_LIT:Name>' , [ ] ) <EOL> class MockRallyRESTResponse ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , items ) : <EOL> self . items = iter ( items ) <EOL> self . resultCount = len ( items ) <EOL> self . _item_type = '<STR_LIT>' <EOL> self . status_code = <NUM_LIT:200> <EOL> self . errors = [ ] <EOL> self . warnings = [ ] <EOL> def __iter__ ( self ) : <EOL> return self . items <EOL> def next ( self ) : <EOL> return self . items . next ( ) </s>
