Skip to content

Commit 7f5d59d

Browse files
fix find_in_po. Make it Windows compatible (#2714)
Use os.get_terminal_size() instead of stty size for width --------- Co-authored-by: Marco Richetta <marco.richetta@mercadolibre.com>
1 parent f5b7231 commit 7f5d59d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

scripts/find_in_po.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import functools
55
from glob import glob
66
import multiprocessing
7-
import os
7+
from shutil import get_terminal_size
88
from textwrap import fill
99

1010
import regex # fades
@@ -31,11 +31,8 @@ def _get_file_entries(pattern, width, filename):
3131

3232
def find_in_po(pattern):
3333
pattern = regex.compile(pattern)
34-
try:
35-
_, columns = os.popen("stty size", "r").read().split()
36-
available_width = int(columns) // 2 - 3
37-
except:
38-
available_width = 80 // 2 - 3
34+
columns = get_terminal_size().columns
35+
available_width = columns // 2 - 3
3936

4037
# Find entries in parallel
4138
get_file_entries = functools.partial(_get_file_entries, pattern, available_width)

0 commit comments

Comments
 (0)