Skip to content

Commit

Permalink
use textwrap.shorten()
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Dec 19, 2024
1 parent 41b2c23 commit a71ea61
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/src/main/python/opengrok_tools/utils/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import os
import signal
import subprocess
import textwrap
import threading
import time

Expand Down Expand Up @@ -211,7 +212,7 @@ def run(self):

# Assuming that self.max_line_length is bigger than 3.
if self.max_line_length > 0 and len(line) > self.max_line_length:
line = line[:self.max_line_length] + "..."
line = textwrap.shorten(line, width=self.max_line_length, placeholder="...")

# Shorten the list to be one less than the maximum because a line is going to be added.
if self.max_lines > 0 and len(self.out) >= self.max_lines:
Expand Down

0 comments on commit a71ea61

Please sign in to comment.