Skip to content

Commit 5ef34be

Browse files
committed
Narrowed colorama import to Windows users
1 parent c39d18d commit 5ef34be

4 files changed

Lines changed: 4 additions & 6 deletions

File tree

remove-json-keys/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ license-files = [
1818
"docs/LICENSE.md",
1919
]
2020
dependencies = [
21-
"colorama>=0.4.6,<1.0.0",
21+
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
2222
]
2323
requires-python = ">=3.6,<4.0"
2424
keywords = [

remove-json-keys/src/remove_json_keys/lib/log.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, sys
22
from types import SimpleNamespace as sns
3-
import colorama
3+
if sys.platform == 'win32' : import colorama ; colorama.init() # enable ANSI color support
44

55
try:
66
terminal_width = os.get_terminal_size()[0]
@@ -18,7 +18,6 @@
1818
dy='\x1b[33m', # dark yellow
1919
gry='\x1b[90m' # gray
2020
)
21-
colorama.init() # enable compatibility w/ Windows
2221

2322
def data(msg, *args, **kwargs):
2423
print(f'\n{colors.bw}{msg.format(*args, **kwargs)}{colors.nc}')

translate-messages/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ license-files = [
1818
"docs/LICENSE.md",
1919
]
2020
dependencies = [
21-
"colorama>=0.4.6,<1.0.0",
21+
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
2222
"requests>=2.32.0,<3.0.0",
2323
"translate>=3.8.0,<4.0.0",
2424
]

translate-messages/src/translate_messages/lib/log.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, sys
22
from types import SimpleNamespace as sns
3-
import colorama
3+
if sys.platform == 'win32' : import colorama ; colorama.init() # enable ANSI color support
44

55
try:
66
terminal_width = os.get_terminal_size()[0]
@@ -18,7 +18,6 @@
1818
dy='\x1b[33m', # dark yellow
1919
gry='\x1b[90m' # gray
2020
)
21-
colorama.init() # enable compatibility w/ Windows
2221

2322
def data(msg, *args, **kwargs):
2423
print(f'\n{colors.bw}{msg.format(*args, **kwargs)}{colors.nc}')

0 commit comments

Comments
 (0)