def __init__(self) -> None: self.topics: tuple[dict[str, str], ...] self.topic_limit: int = 50 self.page_num: int = 1 self.topic_title: str self.topic_url: str init_colors()
def colored(text, color): if print_color: if not use_html: init_colors(strip=False) return color + text + Fore.RESET else: return htmlma.htmlColored(color,text) else: return text
def __init__(self): readline.clear_history() init_colors() self._prompt_value = self._prompt_empty_value self._prompt_mutex = threading.Lock() self._prompt_not_empty = threading.Condition(self._prompt_mutex) self._prompt_has_waiters = True self._stdin_listener_thread = None self._stdin_listener_event = threading.Event() self._stdin_listener_event.clear()
def run(): # required for colors to work on windows systems init_colors() print 'Interneting for price data...' while (1): data = get_price_data() # clear the console window os.system('cls' if os.name == 'nt' else 'clear') print_price_data(data) time.sleep(REFRESH_INTERVAL) print '\n...'
def colored(text, color): if print_color: init_colors() return color + text + Fore.RESET else: return text
import os from contextlib import contextmanager from pathlib import Path from typing import Generator from colorama import init as init_colors from pkg_resources import resource_isdir, resource_listdir init_colors() # For Windows environment from colorama import Fore, Style def fg(text, color=Fore.WHITE): """텍스트를 지정된 ANSI 컬러로 출력합니다.""" return f"{color}{text}{Fore.RESET}" def bold(text, color=Fore.WHITE): """텍스트를 지정된 ANSI 컬러와 밝기 효과를 주어 출력합니다.""" return f"{Style.BRIGHT}{color}{text}{Style.RESET_ALL}" @contextmanager def cwd(path: Path) -> Generator: """Helper to guarantee work in the path only during the context. Restore previous working directory when exit the context block. """ oldpwd = os.getcwd() os.chdir(path)
from copy import copy from os import linesep, system from pdb import set_trace from time import sleep from colorama import init as init_colors, Fore, Back, Style # Colorama needs to mess with some stuff on windows before it will work init_colors() # exploration frame FRAME = ((0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)) # color index COLORS = ( Back.BLACK, # wall Back.GREEN, # floor Back.BLUE, # water Back.RED, # lava Back.WHITE, # passable fog Back.WHITE) # impassable fog # a drawing of a skull SKULL = r''' _______ / _ _ \ | (_) (_) | \ ^ / |,,,,,| \_____/