Skip to content

Commit

Permalink
Update apt-task.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfospealain authored May 11, 2018
1 parent c4accf2 commit 77cb6cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apt-task.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ def install(self, task):
else:
return apt_command + " " + " ".join(sorted(packages))

def symbol(self, value):
"""
Returns a > or < symbol for rounded values not quite 100 or 0.
"""
return ("<" if value < 100 and value >= 99.5 else (">" if value > 0 and value < 0.5 else " "))

def report(self, orphans=False):
"""
Print on task/metapackage installation statistics.
Expand All @@ -403,14 +409,12 @@ def report(self, orphans=False):
metapackage = task
if task in self.tasks:
percentage = self.task_status(task)[1]
symbol = ("<" if percentage < 100 and percentage >= 99.5 else " ")
print((symbol + str(round(percentage)) + "%").rjust(5), sep="", end="")
print((self.symbol(percentage) + str(round(percentage)) + "%").rjust(5), sep="", end="")
else:
print(" - ", end="")
if metapackage in self.metapackages:
percentage = self.metapackage_status(metapackage)[1]
symbol = ("<" if percentage < 100 and percentage >= 99.5 else " ")
print(" |", (symbol + str(round(percentage)) + "%").rjust(5), sep="", end="")
print(" |", (self.symbol(percentage) + str(round(percentage)) + "%").rjust(5), sep="", end="")
else:
print(" | - ", sep="", end="")
if task != metapackage:
Expand Down

0 comments on commit 77cb6cf

Please sign in to comment.