Skip to content

Commit

Permalink
Added multi-line msg support to print_trunc() ↞ [auto-sync from htt…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Feb 7, 2025
1 parent d5e3d96 commit bd2ee6c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions greasemonkey/utils/remove-json-keys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
Script: remove-json-keys.py
Version: 2025.2.7
Version: 2025.2.7.1
Description: Remove key/value pairs from json_folder/**.json
Author: Adam Lui
URL: https://github.com/adamlui/python-utils
Expand All @@ -13,7 +13,10 @@
# UI initializations
os.system('color') ; print('\033[0;92m') # set font to bright green
terminal_width = os.get_terminal_size()[0]
def print_trunc(msg, end='\n') : print(msg if len(msg) < terminal_width else msg[0:terminal_width-4] + '...', end=end)
def print_trunc(msg, end='\n'):
truncated_lines = [
line if len(line) < terminal_width else line[:terminal_width - 4] + '...' for line in msg.splitlines() ]
print('\n'.join(truncated_lines), end=end)

print('')

Expand Down

0 comments on commit bd2ee6c

Please sign in to comment.