mirror of https://github.com/docker/compose.git
Reorganize conditional branches to improve readability
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
b8b4c84573
commit
c573fcc70a
|
@ -19,30 +19,33 @@ def stream_output(output, stream):
|
||||||
if not is_progress_event:
|
if not is_progress_event:
|
||||||
print_output_event(event, stream, is_terminal)
|
print_output_event(event, stream, is_terminal)
|
||||||
stream.flush()
|
stream.flush()
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not is_terminal:
|
||||||
|
continue
|
||||||
|
|
||||||
# if it's a progress event and we have a terminal, then display the progress bars
|
# if it's a progress event and we have a terminal, then display the progress bars
|
||||||
elif is_terminal:
|
image_id = event.get('id')
|
||||||
image_id = event.get('id')
|
if not image_id:
|
||||||
if not image_id:
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
if image_id in lines:
|
if image_id in lines:
|
||||||
diff = len(lines) - lines[image_id]
|
diff = len(lines) - lines[image_id]
|
||||||
else:
|
else:
|
||||||
lines[image_id] = len(lines)
|
lines[image_id] = len(lines)
|
||||||
stream.write("\n")
|
stream.write("\n")
|
||||||
diff = 0
|
diff = 0
|
||||||
|
|
||||||
# move cursor up `diff` rows
|
# move cursor up `diff` rows
|
||||||
stream.write("%c[%dA" % (27, diff))
|
stream.write("%c[%dA" % (27, diff))
|
||||||
|
|
||||||
print_output_event(event, stream, is_terminal)
|
print_output_event(event, stream, is_terminal)
|
||||||
|
|
||||||
if 'id' in event:
|
if 'id' in event:
|
||||||
# move cursor back down
|
# move cursor back down
|
||||||
stream.write("%c[%dB" % (27, diff))
|
stream.write("%c[%dB" % (27, diff))
|
||||||
|
|
||||||
stream.flush()
|
stream.flush()
|
||||||
|
|
||||||
return all_events
|
return all_events
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue