Skip to content
Myr

Make clear() a noop if not connected to a terminal.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 657cdd9 · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:click/termui.py+4 added-2 removed
1 unmodified line
2import sys3import struct45from ._compat import raw_input, PY2, text_type, string_types, \6 get_best_encoding, colorama6 get_best_encoding, colorama, isatty7from .utils import echo8from .exceptions import Abort, UsageError9from .types import convert_type10
243 unmodified lines
254255def clear():256 """Clears the terminal screen. This will have the effect of clearing257 the whole visible space of the terminal and moving the cursor to the258 top left.258 top left. This does not do anything if not connected to a terminal.259260 .. versionadded:: 2.0261 """262 if not isatty(sys.stdout):263 return264 # If we're on windows and we don't have colorama available, then we265 # clear the screen by shelling out. Otherwise we can use an escape266 # sequence.267 if sys.platform.startswith('win') and colorama is None:
3 unmodified lines