diff --git a/pype.py b/pype.py index e90c257595..992e0c35ba 100644 --- a/pype.py +++ b/pype.py @@ -48,8 +48,11 @@ from igniter.tools import load_environments, add_acre_to_sys_path from igniter import BootstrapRepos -add_acre_to_sys_path() -import acre +try: + import acre +except ImportError: + add_acre_to_sys_path() + import acre def set_environments() -> None: @@ -101,18 +104,9 @@ def set_modules_environments(): def boot(): """Bootstrap Pype.""" - art = r""" - ____________ - /\ ___ \ - \ \ \/_\ \ - \ \ _____/ ___ ___ ___ - \ \ \___/ ---- \ \\ \\ \ - \ \____\ / \____\ \__\\__\\__\ - \/____/ \/____/ . PYPE Club . - """ - - print(art) + from pype.lib.terminal_splash import play_animation + play_animation() # find pype versions bootstrap = BootstrapRepos() diff --git a/pype/lib/splash.txt b/pype/lib/splash.txt new file mode 100644 index 0000000000..833bcd4b9c --- /dev/null +++ b/pype/lib/splash.txt @@ -0,0 +1,413 @@ + + + + * + + + + + + + .* + + + + + + * + .* + * + + + + . + * + .* + * + . + + . + * + .* + .* + .* + * + . + . + * + .* + .* + .* + * + . + _. + /** + \ * + \* + * + * + . + __. + ---* + \ \* + \ * + \* + * + . + \___. + /* * + \ \ * + \ \* + \ * + \* + . + |____. + /* * + \|\ * + \ \ * + \ \ * + \ \* + \/. + _/_____. + /* * + / \ * + \ \ * + \ \ * + \ \__* + \/__. + __________. + --*-- ___* + \ \ \/_* + \ \ __* + \ \ \_* + \ \____\* + \/____/. + \____________ . + /* ___ \* + \ \ \/_\ * + \ \ _____* + \ \ \___/* + \ \____\ * + \/____/ . + |___________ . + /* ___ \ * + \|\ \/_\ \ * + \ \ _____/ * + \ \ \___/ * + \ \____\ / * + \/____/ \. + _/__________ . + /* ___ \ * + / \ \/_\ \ * + \ \ _____/ * + \ \ \___/ ---* + \ \____\ / \__* + \/____/ \/__. + ____________ . + --*-- ___ \ * + \ \ \/_\ \ * + \ \ _____/ * + \ \ \___/ ---- * + \ \____\ / \____\* + \/____/ \/____/. + ____________ + /\ ___ \ . + \ \ \/_\ \ * + \ \ _____/ * + \ \ \___/ ---- * + \ \____\ / \____\ . + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ . + \ \ _____/ * + \ \ \___/ ---- * + \ \____\ / \____\ . + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ . + \ \ \___/ ---- * + \ \____\ / \____\ . + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ + \ \ \___/ ---- * + \ \____\ / \____\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ + \ \ \___/ ---- . + \ \____\ / \____\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ _ + \ \ \___/ ---- + \ \____\ / \____\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- + \ \____\ / \____\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ + \ \____\ / \____\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ + \ \____\ / \____\ \ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ + \ \____\ / \____\ __\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ + \ \____\ / \____\ \__\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ \ + \ \____\ / \____\ \__\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ + \ \ \___/ ---- \ \ + \ \____\ / \____\ \__\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___. + \ \ \___/ ---- \ \\ + \ \____\ / \____\ \__\, + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ . + \ \ \___/ ---- \ \\ + \ \____\ / \____\ \__\\, + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ _. + \ \ \___/ ---- \ \\\ + \ \____\ / \____\ \__\\\ + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ __. + \ \ \___/ ---- \ \\ \ + \ \____\ / \____\ \__\\_/. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___. + \ \ \___/ ---- \ \\ \\ + \ \____\ / \____\ \__\\__\. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ . + \ \ \___/ ---- \ \\ \\ + \ \____\ / \____\ \__\\__\\. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ _. + \ \ \___/ ---- \ \\ \\\ + \ \____\ / \____\ \__\\__\\. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ __. + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\_. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ __. + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__. + \/____/ \/____/ + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ * + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ O* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ .oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ ..oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . .oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . p.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . Py.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYp.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPe.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE .oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE c.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE C1.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE ClU.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE CluB.oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE Club .oO* + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE Club . .. + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE Club . .. + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE Club . . + ____________ + /\ ___ \ + \ \ \/_\ \ + \ \ _____/ ___ ___ ___ + \ \ \___/ ---- \ \\ \\ \ + \ \____\ / \____\ \__\\__\\__\ + \/____/ \/____/ . PYPE Club . diff --git a/pype/lib/terminal.py b/pype/lib/terminal.py index 61d074f474..afaca8241a 100644 --- a/pype/lib/terminal.py +++ b/pype/lib/terminal.py @@ -13,11 +13,10 @@ import re import os import sys -noColorama = False -try: - from colorama import Fore, Style, init, ansitowin32 -except ImportError: - noColorama = True +import blessed + + +term = blessed.Terminal() class Terminal: @@ -30,40 +29,37 @@ class Terminal: """ # shortcuts for colorama codes - if noColorama: - _SB = _RST = _LR = _LG = _LB = _LM = _R = _G = _B = _C = _Y = _W = "" - _LY = "" - else: - _SB = Style.BRIGHT - _RST = Style.RESET_ALL - _LR = Fore.LIGHTRED_EX - _LG = Fore.LIGHTGREEN_EX - _LB = Fore.LIGHTBLUE_EX - _LM = Fore.LIGHTMAGENTA_EX - _LY = Fore.LIGHTYELLOW_EX - _R = Fore.RED - _G = Fore.GREEN - _B = Fore.BLUE - _C = Fore.CYAN - _Y = Fore.YELLOW - _W = Fore.WHITE + + _SB = term.bold + _RST = "" + _LR = term.tomato2 + _LG = term.aquamarine3 + _LB = term.turquoise2 + _LM = term.slateblue2 + _LY = term.gold + _R = term.red + _G = term.green + _B = term.blue + _C = term.cyan + _Y = term.yellow + _W = term.white # dictionary replacing string sequences with colorized one _sdict = { - r">>> ": _SB + _G + r">>> " + _RST, + r">>> ": _SB + _LG + r">>> " + _RST, r"!!!(?!\sCRI|\sERR)": _SB + _R + r"!!! " + _RST, r"\-\-\- ": _SB + _C + r"--- " + _RST, - r"\*\*\*(?!\sWRN)": _SB + _LM + r"***" + _RST, + r"\*\*\*(?!\sWRN)": _SB + _LY + r"***" + _RST, r"\*\*\* WRN": _SB + _LY + r"*** WRN" + _RST, - r" \- ": _SB + _Y + r" - " + _RST, + r" \- ": _SB + _LY + r" - " + _RST, r"\[ ": _SB + _LG + r"[ " + _RST, r"\]": _SB + _LG + r"]" + _RST, r"{": _LG + r"{", r"}": r"}" + _RST, r"\(": _LY + r"(", r"\)": r")" + _RST, - r"^\.\.\. ": _SB + _LM + r"... " + _RST, + r"^\.\.\. ": _SB + _LR + r"... " + _RST, r"!!! ERR: ": _SB + _LR + r"!!! ERR: " + _RST, r"!!! CRI: ": @@ -73,8 +69,7 @@ class Terminal: } def __init__(self): - if not noColorama: - init() + pass @staticmethod def _multiple_replace(text, adict): @@ -108,11 +103,6 @@ class Terminal: str: Colorized message. """ - if noColorama: - print(message) - return message - if not isinstance(sys.stdout, ansitowin32.StreamWrapper): - init() colorized = Terminal.log(message) print(colorized) diff --git a/pype/lib/terminal_splash.py b/pype/lib/terminal_splash.py new file mode 100644 index 0000000000..7a94f2243e --- /dev/null +++ b/pype/lib/terminal_splash.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +"""Pype terminal animation.""" +import blessed +from pathlib import Path +from time import sleep + + +term = blessed.Terminal() + + +def play_animation(): + """Play ASCII art Pype animation.""" + print(term.home + term.clear) + frame_size = 7 + splash_file = Path(__file__).parent / "splash.txt" + with splash_file.open("r") as sf: + animation = sf.readlines() + + animation_length = int(len(animation) / frame_size) + current_frame = 0 + for _ in range(animation_length): + frame = "" + y = 0 + for scanline in animation[current_frame:current_frame + frame_size]: + frame += scanline + y += 1 + + with term.location(0, 0): + # term.aquamarine3_bold(frame) + print(f"{term.bold}{term.aquamarine3}{frame}{term.normal}") + + sleep(0.02) + current_frame += frame_size + print(term.move_y(7)) diff --git a/requirements.txt b/requirements.txt index ac197b9b1e..24cf4f31c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ aiohttp appdirs arrow +blessed certifi Click clique==1.5.0