def find_paths_breadth_first(from_target, to_target, log):
 log.debug(u'Looking for all paths from {} to {}'.format(from_target.address.reference(), to_target.address.reference()))
 if (from_target == to_target):
  (yield [from_target])
  return
 visited_edges = set()
 to_walk_paths = deque([[from_target]])
 while (len(to_walk_paths) > 0):
  cur_path = to_walk_paths.popleft()
  target = cur_path[(-1)]
  if (len(cur_path) > 1):
   prev_target = cur_path[(-2)]
  else:
   prev_target = None
  current_edge = (prev_target, target)
  if (current_edge not in visited_edges):
   for dep in target.dependencies:
    dep_path = (cur_path + [dep])
    if (dep == to_target):
     (yield dep_path)
    else:
     to_walk_paths.append(dep_path)
   visited_edges.add(current_edge)

def find_paths_breadth_first ( from_target , to_target , log ) : log . debug ( u'Looking for all paths from {} to {}' . format ( from_target . address . reference ( ) , to_target . address . reference ( ) ) ) if ( from_target == to_target ) : ( yield [ from_target ] ) return visited_edges = set ( ) to_walk_paths = deque ( [ [ from_target ] ] ) while ( len ( to_walk_paths ) > 0 ) : cur_path = to_walk_paths . popleft ( ) target = cur_path [ ( - 1 ) ] if ( len ( cur_path ) > 1 ) : prev_target = cur_path [ ( - 2 ) ] else : prev_target = None current_edge = ( prev_target , target ) if ( current_edge not in visited_edges ) : for dep in target . dependencies : dep_path = ( cur_path + [ dep ] ) if ( dep == to_target ) : ( yield dep_path ) else : to_walk_paths . append ( dep_path ) visited_edges . add ( current_edge )
yields the paths between from_target to to_target if they exist .