Skip to content

Commit

Permalink
cli.User: Fix progress output.
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Smeets committed Jan 21, 2024
1 parent 892fc27 commit 4784c58
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions gramps/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,35 @@ def begin_progress(self, title, message, steps):
:type steps: int
:returns: none
"""
self._fileout.write(message)
self.steps = steps
self.current_step = 0
if self.steps == 0:
self._fileout.write(_SPINNER[self.current_step])
else:
self._fileout.write("00%")
self.display_progress()
self._fileout.write(message)

def step_progress(self):
"""
Advance the progress meter.
"""
self.current_step += 1
if self.steps == 0:
self.current_step %= 4
self._fileout.write("\r %s " % _SPINNER[self.current_step])
else:
percent = int((float(self.current_step) / self.steps) * 100)
self._fileout.write("\r%02d%%" % percent)
self.display_progress()

def end_progress(self):
"""
Stop showing the progress indicator to the user.
"""
self._fileout.write("\r100%\n")
self.display_progress(end=True)

def display_progress(self, end=False):
if end:
self.steps = self.current_step = 1
if self.steps == 0:
self.current_step %= 4
self._fileout.write("\r %s " % _SPINNER[self.current_step])
else:
percent = int((float(self.current_step) / self.steps) * 100)
self._fileout.write("\r%3d%% " % percent)
if end:
self._fileout.write("\n")

def prompt(
self,
Expand Down

0 comments on commit 4784c58

Please sign in to comment.