From becf18963fbc1dd049f29799d433f3d0b0f27b7b Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 12 Jan 2022 21:42:58 +0000 Subject: added isatty for colors outputs. --- kaminokumo | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kaminokumo b/kaminokumo index a347c26..aa94a56 100755 --- a/kaminokumo +++ b/kaminokumo @@ -22,6 +22,11 @@ class bcolors: UNDERLINE = "\033[4m" +green = bcolors.OKGREEN if sys.stdout.isatty() else "" +blue = bcolors.OKBLUE if sys.stdout.isatty() else "" +cyan = bcolors.OKCYAN if sys.stdout.isatty() else "" + + class Argparser(object): def __init__(self): parser = argparse.ArgumentParser() @@ -106,11 +111,7 @@ def manga_scrape(): for thing in search: # re_res.append(re.findall("Chapter [0-9]*[.[0-9]*]?", thing.text)) re_res.append( - bcolors.OKGREEN - + thing["title"] - + " >>> " - + bcolors.OKCYAN - + thing["href"] + green + thing["title"] + " >>> " + blue + thing["href"] ) try: # result += name + "-->" + re_res[0][0] + "\n" -- cgit v1.2.3