nodes: 0, module; 1, function_definition; 2, function_name:capability_functions; 3, parameters; 4, block; 5, identifier:self; 6, identifier:fn; 7, expression_statement; 8, if_statement; 9, comment:# build a list of functions to call; 10, expression_statement; 11, for_statement; 12, comment:# sort them by z-index; 13, expression_statement; 14, if_statement; 15, comment:# now yield them in order; 16, for_statement; 17, comment:"""This generator yields functions that match the
          requested capability sorted by z-index."""; 18, identifier:_debug; 19, block; 20, assignment; 21, identifier:cls; 22, attribute; 23, block; 24, call; 25, identifier:_debug; 26, block; 27, pattern_list; 28, identifier:fns; 29, block; 30, expression_statement; 31, identifier:fns; 32, list; 33, identifier:self; 34, identifier:capabilities; 35, expression_statement; 36, if_statement; 37, if_statement; 38, attribute; 39, argument_list; 40, expression_statement; 41, identifier:xindx; 42, identifier:xfn; 43, if_statement; 44, expression_statement; 45, call; 46, assignment; 47, identifier:_debug; 48, block; 49, identifier:xfn; 50, block; 51, identifier:fns; 52, identifier:sort; 53, keyword_argument; 54, call; 55, identifier:_debug; 56, block; 57, yield; 58, attribute; 59, argument_list; 60, identifier:xfn; 61, call; 62, expression_statement; 63, expression_statement; 64, identifier:key; 65, lambda; 66, attribute; 67, argument_list; 68, expression_statement; 69, identifier:xfn; 70, identifier:Collector; 71, identifier:_debug; 72, string:"capability_functions %r"; 73, identifier:fn; 74, identifier:getattr; 75, argument_list; 76, call; 77, call; 78, lambda_parameters; 79, subscript; 80, identifier:Collector; 81, identifier:_debug; 82, string:"    - fns: %r"; 83, identifier:fns; 84, call; 85, identifier:cls; 86, identifier:fn; 87, None; 88, attribute; 89, argument_list; 90, attribute; 91, argument_list; 92, identifier:v; 93, identifier:v; 94, integer:0; 95, attribute; 96, argument_list; 97, identifier:Collector; 98, identifier:_debug; 99, string:"    - cls, xfn: %r, %r"; 100, identifier:cls; 101, identifier:xfn; 102, identifier:fns; 103, identifier:append; 104, tuple; 105, identifier:Collector; 106, identifier:_debug; 107, string:"    - yield xfn: %r"; 108, identifier:xfn; 109, call; 110, identifier:xfn; 111, identifier:getattr; 112, argument_list; 113, identifier:cls; 114, string; 115, None; 116, string_content:_zindex
code: def capability_functions(self, fn):
          """This generator yields functions that match the
          requested capability sorted by z-index."""
          if _debug: Collector._debug("capability_functions %r", fn)
  
          # build a list of functions to call
          fns = []
          for cls in self.capabilities:
              xfn = getattr(cls, fn, None)
              if _debug: Collector._debug("    - cls, xfn: %r, %r", cls, xfn)
              if xfn:
                  fns.append( (getattr(cls, '_zindex', None), xfn) )
  
          # sort them by z-index
          fns.sort(key=lambda v: v[0])
          if _debug: Collector._debug("    - fns: %r", fns)
  
          # now yield them in order
          for xindx, xfn in fns:
              if _debug: Collector._debug("    - yield xfn: %r", xfn)
              yield xfn