From 476ded38f0dafe015c1da9a19b01bd0b37f51cba Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Wed, 22 Jan 2025 23:02:52 +0200 Subject: [PATCH 1/2] Only require colorama on Windows --- requirements.txt | 2 +- tldr.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index f49a8fb..6be8b30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ termcolor -colorama +colorama; sys_platform=='win32' shtab>=1.3.10 diff --git a/tldr.py b/tldr.py index 3749988..967ebbc 100755 --- a/tldr.py +++ b/tldr.py @@ -15,7 +15,6 @@ from urllib.request import urlopen, Request from urllib.error import HTTPError, URLError from termcolor import colored -import colorama # Required for Windows import shtab __version__ = "3.3.0" @@ -624,7 +623,9 @@ def main() -> None: options = parser.parse_args() - colorama.init(strip=options.color) + if sys.platform == "win32": + import colorama + colorama.init(strip=options.color) if options.color is False: os.environ["FORCE_COLOR"] = "true" From 84df70abd3a3254db3025b24d228d9a898116abf Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Thu, 27 Mar 2025 17:50:30 +0530 Subject: [PATCH 2/2] fix: indentation in tldr.py Signed-off-by: K.B.Dharun Krishna --- tldr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tldr.py b/tldr.py index c0bde9e..afbde86 100755 --- a/tldr.py +++ b/tldr.py @@ -657,7 +657,6 @@ def main() -> None: display_option_length = "long" if options.short_options and options.long_options: display_option_length = "both" - if sys.platform == "win32": import colorama colorama.init(strip=options.color)