Skip to content

Commit a1621de

Browse files
committed
Added multi-line msg support to print_trunc()
1 parent 9ef6b49 commit a1621de

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

remove-json-keys/remove-json-keys.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Script: remove-json-keys.py
3-
Version: 2025.2.7
3+
Version: 2025.2.7.1
44
Description: Remove key/value pairs from json_folder/**.json
55
Author: Adam Lui
66
URL: https://github.com/adamlui/python-utils
@@ -13,7 +13,10 @@
1313
# UI initializations
1414
os.system('color') ; print('\033[0;92m') # set font to bright green
1515
terminal_width = os.get_terminal_size()[0]
16-
def print_trunc(msg, end='\n') : print(msg if len(msg) < terminal_width else msg[0:terminal_width-4] + '...', end=end)
16+
def print_trunc(msg, end='\n'):
17+
truncated_lines = [
18+
line if len(line) < terminal_width else line[:terminal_width - 4] + '...' for line in msg.splitlines() ]
19+
print('\n'.join(truncated_lines), end=end)
1720

1821
print('')
1922

translate-messages/translate-en-messages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Script: translate-en-messages.py
3-
Version: 2024.11.24.1
3+
Version: 2025.2.7
44
Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55
Author: Adam Lui
66
Homepage: https://github.com/adamlui/python-utils
@@ -22,7 +22,10 @@
2222

2323
# UI initializations
2424
terminal_width = os.get_terminal_size()[0]
25-
def print_trunc(msg, end='\n') : print(msg if len(msg) < terminal_width else msg[0:terminal_width-4] + '...', end=end)
25+
def print_trunc(msg, end='\n'):
26+
truncated_lines = [
27+
line if len(line) < terminal_width else line[:terminal_width - 4] + '...' for line in msg.splitlines() ]
28+
print('\n'.join(truncated_lines), end=end)
2629
def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:terminal_width])
2730

2831
print('')

0 commit comments

Comments
 (0)