class_docstr: Dispatch calls to a chain of commands until some func can handle it
  
  Usage: instantiate, execute "add" to add commands (with optional
  priority), execute normally via f() calling mechanism.
class_docstr_tok: ["Dispatch","calls","to","a","chain","of","commands","until","some","func","can","handle","it","Usage",":","instantiate",",","execute","``","add","''","to","add","commands","(","with","optional","priority",")",",","execute","normally","via","f","(",")","calling","mechanism","."]
docstr: Command chain is called just like normal func.
  
  This will call all funcs in chain with the same args as were given to
  this function, and return the result of first func that didn't raise
  TryNext
docstr_tok: ["Command","chain","is","called","just","like","normal","func",".","This","will","call","all","funcs","in","chain","with","the","same","args","as","were","given","to","this","function",",","and","return","the","result","of","first","func","that","did","n't","raise","TryNext"]
code: def __call__(self, *args, **kw):
      """Command chain is called just like normal func.
  
      This will call all funcs in chain with the same args as were given to
      this function, and return the result of first func that didn't raise
      TryNext"""
      last_exc = TryNext()
      for prio, cmd in self.chain:
          # print "prio",prio,"cmd",cmd #dbg
          try:
              return cmd(*args, **kw)
          except TryNext as exc:
              last_exc = exc
      # if no function will accept it, raise TryNext up to the caller
      raise last_exc
  
imports: import os
  import subprocess
  import warnings
  import sys
  from IPython.core.error import TryNext
  import tempfile
label_desc: Use image node_id 2 for calling the CommandChainDispatcher obj's underlying member method code with example usage: obj.__call__() and returns: cmd