1   
  2   
  3   
  4   
  5   
  6  """ 
  7  This module is a collection of unrelated algorithms, that works on code creators 
  8  tree. 
  9  """ 
 10   
 11  from pyplusplus.decl_wrappers.algorithm import * 
 12   
 13   
 14  import types  
 15  import namespace 
 29   
 30      creators = [] 
 31      if isinstance( creator_or_creators, types.ListType ): 
 32          creators.extend( creator_or_creators ) 
 33      else: 
 34          creators.append( creator_or_creators ) 
 35      answer = [] 
 36      for creator in creators: 
 37          answer.extend( proceed_single( creator ) ) 
 38      return answer 
 39   
 52   
 53      if isinstance( creator_or_creators, types.ListType ): 
 54          for creator in creator_or_creators: 
 55              for internal in proceed_single( creator ): 
 56                  yield internal 
 57      else: 
 58          for internal in proceed_single( creator_or_creators ): 
 59              yield internal 
 60   
 61  """ 
 62  make_flatten - function that will create flat representation of code creators tree. 
 63  """ 
 64  make_flatten_list = _make_flatten_list 
 65  make_flatten = _make_flatten_list 
 68      """ 
 69      This class is used as container for different find algorithms. 
 70      """ 
 71      "creator_finder - this class used as namespace" 
 72       
 73      @staticmethod 
 75          """Finds code creator by declaration.  
 76          declaration_matcher should be callable, that takes single argument  
 77          declaration, and returns True or False 
 78          where - code creator or list of code creators 
 79          This function returns a list of all relevant code creators  
 80          """ 
 81          import declaration_based  
 82          search_area = where 
 83          if recursive: 
 84              search_area = make_flatten_generator( where ) 
 85          return filter( lambda inst: isinstance( inst, declaration_based.declaration_based_t ) \ 
 86                                      and declaration_matcher( inst.declaration ) 
 87                         , search_area ) 
  88       
 89      @staticmethod 
 95       
 96      @staticmethod 
 98          search_area = where 
 99          if recursive: 
100              search_area = make_flatten_generator( where ) 
101          return filter( lambda inst: isinstance( inst, what ), search_area ) 
  102   
105