Skip to content

Commit

Permalink
Don't expose the internal method
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Oct 29, 2020
1 parent 8f866bf commit 81d0230
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions halo/halo.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,12 @@ def _pop_stream_content_until_self(self, clear_self=False):

if lines_to_erase > 0:
# Move cursor up n lines
self._write("\033[{}A".format(lines_to_erase))
self._write_stream("\033[{}A".format(lines_to_erase))
# Erase rest content
self._write(self.CLEAR_REST)
self._write_stream(self.CLEAR_REST)
return "".join(reversed(erased_content))

def _write(self, s):
def _write_stream(self, s):
"""Write to the stream, if writable
Parameters
----------
Expand All @@ -338,7 +338,7 @@ def _write(self, s):
if self._check_stream():
self._stream.write(s)

def write(self, s, overwrite=False):
def _write(self, s, overwrite=False):
"""Write to the stream and keep following lines unchanged.
Parameters
----------
Expand All @@ -349,9 +349,9 @@ def write(self, s, overwrite=False):
"""
with Halo._lock:
erased_content = self._pop_stream_content_until_self(overwrite)
self._write(s)
self._write_stream(s)
# Write back following lines
self._write(erased_content)
self._write_stream(erased_content)
self._content = s if overwrite else self._content + s

def _hide_cursor(self):
Expand Down Expand Up @@ -441,7 +441,7 @@ def clear(self):
with Halo._lock:
erased_content = self._pop_stream_content_until_self(True)
self._content = ""
self._write(erased_content)
self._write_stream(erased_content)
return self

def _render_frame(self):
Expand All @@ -455,9 +455,9 @@ def _render_frame(self):
frame = self.frame()
output = "\r{}\n".format(frame)
try:
self.write(output, True)
self._write(output, True)
except UnicodeEncodeError:
self.write(encode_utf_8_text(output), True)
self._write(encode_utf_8_text(output), True)

def render(self):
"""Runs the render until thread flag is set.
Expand Down Expand Up @@ -663,8 +663,8 @@ def stop_and_persist(self, symbol=" ", text=None):
)

try:
self.write(output)
self._write(output)
except UnicodeEncodeError:
self.write(encode_utf_8_text(output))
self._write(encode_utf_8_text(output))

return self

0 comments on commit 81d0230

Please sign in to comment.