def attach_ordered_steps(workflow, steps):
 ordered_steps = order_workflow_steps(steps)
 workflow.has_cycles = (not bool(ordered_steps))
 for (i, step) in enumerate((ordered_steps or steps)):
  step.order_index = i
  workflow.steps.append(step)

def attach_ordered_steps ( workflow , steps ) : ordered_steps = order_workflow_steps ( steps ) workflow . has_cycles = ( not bool ( ordered_steps ) ) for ( i , step ) in enumerate ( ( ordered_steps or steps ) ) : step . order_index = i workflow . steps . append ( step )
attempt to topologically order steps and attach to workflow .