Skip to content

Commit

Permalink
JobStatusDisplay: introduce MAX_DISPLAY_WIDTH constant
Browse files Browse the repository at this point in the history
Values that belong together and may only be changed at the same time
should be combined in a common constant. So let's do this.

Signed-off-by: Florian Schmaus <flow@gentoo.org>
  • Loading branch information
Flowdalic committed Aug 31, 2024
1 parent 2b47b68 commit 8f34208
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/_emerge/JobStatusDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class JobStatusDisplay:
MAX_DISPLAY_WIDTH = 100

_bound_properties = ("curval", "failed", "running")

# Don't update the display unless at least this much
Expand Down Expand Up @@ -65,14 +67,14 @@ def __init__(self, quiet=False, xterm_titles=True):
if self._isatty:
width = portage.output.get_term_size()[1]
else:
width = 100
width = MAX_DISPLAY_WIDTH
self._set_width(width)

def _set_width(self, width):
if width == getattr(self, "width", None):
return
if width <= 0 or width > 100:
width = 100
if width <= 0 or width > MAX_DISPLAY_WIDTH:
width = MAX_DISPLAY_WIDTH
object.__setattr__(self, "width", width)
object.__setattr__(self, "_jobs_column_width", width - 32)

Expand Down

0 comments on commit 8f34208

Please sign in to comment.