PKbN}HIIbashcolor/__init__.py# -*- coding: utf-8 -*- # see also: http://misc.flogisoft.com/bash/tip_colors_and_formatting RESET = 0 BLACK = 30 RED = 31 GREEN = 32 BROWN = 33 BLUE = 34 PURPLE = 35 CYAN = 36 LIGHT_GRAY = 37 _OTHER = 38 DEFAULT = 39 DARK_GRAY = 90 LIGHT_RED = 91 LIGHT_GREEN = 92 YELLOW = 93 LIGHT_BLUE = 94 LIGHT_PURPLE = 95 LIGHT_CYAN = 96 WHITE = 97 BOLD = 1 DIM = 2 # not working on Konsole UNDERLINE = 4 BLINK = 5 # not working on Konsole and gnome Terminal INVERSE = 7 HIDDEN = 8 # not working on Konsole _ESC = '\033' _ESC = '\x1b' _BACKGROUND = 10 _RESET_EFFECT = 10 def colorize(text, color=None, background=None, effects=[], color_256=None, background_256=None, with_end=True): start = [] end = [] if color is not None: start.append(color) end.append(DEFAULT) elif color_256 is not None: start += [_OTHER, 5, color_256] end.append(DEFAULT) if background is not None: start.append(background + _BACKGROUND) end.append(DEFAULT + _BACKGROUND) elif background_256 is not None: start += [_OTHER + _BACKGROUND, 5, background_256] end.append(DEFAULT + _BACKGROUND) for effect in effects: start.append(effect) end.append(effect + _RESET_EFFECT) start_code = "%s[%sm" % (_ESC, ';'.join([str(s) for s in start])) if text != '' else '' end_code = "%s[%sm" % (_ESC, ';'.join([str(e) for e in end])) if with_end else '' return "%s%s%s" % (start_code, text, end_code) def print_colors(): color_pivot = [0] color_pivot += [e * 6 + 16 for e in range(37)] color_pivot.append(256) color_pivot_start = color_pivot[:-1] color_pivot_end = color_pivot[1:] color_table = [range(cs, ce) for cs, ce in zip(color_pivot_start, color_pivot_end)] for ct in color_table: text = '' for c in ct: cs = str(c) padding = ''.join([' ' for e in range(3 - len(cs))]) text += colorize(' %s%s ' % (padding, cs), background_256=c, with_end=False) print(text + colorize('', background=DEFAULT)) if __name__ == "__main__": print_colors() PKNQ}H))bashcolor-0.9.1.dist-info/DESCRIPTION.rst# Bash color ## Available colors * BLACK * RED * GREEN * BROWN * BLUE * PURPLE * CYAN * LIGHT_GRAY * DEFAULT * DARK_GRAY * LIGHT_RED * LIGHT_GREEN * YELLOW * LIGHT_BLUE * LIGHT_PURPLE * LIGHT_CYAN * WHITE ## Available effect * BOLD * DIM (not working on Konsole) * UNDERLINE * BLINK (not working on Konsole and Gnome Terminal) * INVERSE * HIDDEN (not working on Konsole) ## Example ```python from bash import colorize, RED, UNDERLINE print(colorize('Red color', RED)) print(colorize('Red background', background=RED)) print(colorize('Underline', effect=UNDERLINE)) ``` ## API ```python def colorize( text, color=None, background=None, effects=[], color_256=None, background_256=None, with_end=True): ``` PKNQ}H#99*bashcolor-0.9.1.dist-info/entry_points.txt[console_scripts] print_colors = bashcolor:print_colors PKNQ}Hhݴ'bashcolor-0.9.1.dist-info/metadata.json{"classifiers": ["Programming Language :: Python :: 3"], "extensions": {"python.commands": {"wrap_console": {"print_colors": "bashcolor:print_colors"}}, "python.details": {"contacts": [{"email": "stephane.brunner@gmail.com", "name": "St\u00e9phane Brunner", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/sbrunner/bashcolor/"}}, "python.exports": {"console_scripts": {"print_colors": "bashcolor:print_colors"}}}, "generator": "bdist_wheel (0.26.0)", "metadata_version": "2.0", "name": "bashcolor", "summary": "A simple library to get colors in the bash terminal", "test_requires": [{"requires": []}], "version": "0.9.1"}PKNQ}H 'bashcolor-0.9.1.dist-info/top_level.txtbashcolor PKNQ}H''\\bashcolor-0.9.1.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any PKNQ}HT_U%%"bashcolor-0.9.1.dist-info/METADATAMetadata-Version: 2.0 Name: bashcolor Version: 0.9.1 Summary: A simple library to get colors in the bash terminal Home-page: https://github.com/sbrunner/bashcolor/ Author: Stéphane Brunner Author-email: stephane.brunner@gmail.com License: UNKNOWN Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 # Bash color ## Available colors * BLACK * RED * GREEN * BROWN * BLUE * PURPLE * CYAN * LIGHT_GRAY * DEFAULT * DARK_GRAY * LIGHT_RED * LIGHT_GREEN * YELLOW * LIGHT_BLUE * LIGHT_PURPLE * LIGHT_CYAN * WHITE ## Available effect * BOLD * DIM (not working on Konsole) * UNDERLINE * BLINK (not working on Konsole and Gnome Terminal) * INVERSE * HIDDEN (not working on Konsole) ## Example ```python from bash import colorize, RED, UNDERLINE print(colorize('Red color', RED)) print(colorize('Red background', background=RED)) print(colorize('Underline', effect=UNDERLINE)) ``` ## API ```python def colorize( text, color=None, background=None, effects=[], color_256=None, background_256=None, with_end=True): ``` PKNQ}Hթ bashcolor-0.9.1.dist-info/RECORDbashcolor/__init__.py,sha256=iCQlBdVyZwQT_x0QujMCg1b8LpCL-F1a9k8Dsfq01CE,2121 bashcolor-0.9.1.dist-info/DESCRIPTION.rst,sha256=6HhfhjpL5Q3I1EQv_pVbAsYVQ5n6S5KnNfHS9Jvx0lo,746 bashcolor-0.9.1.dist-info/METADATA,sha256=VoEzTgbWl-rEsg9EgV3XF-DL__61D7aT9UXFPH8sBSk,1061 bashcolor-0.9.1.dist-info/RECORD,, bashcolor-0.9.1.dist-info/WHEEL,sha256=JTb7YztR8fkPg6aSjc571Q4eiVHCwmUDlX8PhuuqIIE,92 bashcolor-0.9.1.dist-info/entry_points.txt,sha256=F30pCw0yk9WOqsQlyWV8bfraBu6dlbwhhIBU14DESJg,57 bashcolor-0.9.1.dist-info/metadata.json,sha256=6AK0h6-vnwu6EjikWIeG0BoioKTwLDtLjU8TNhUwTNs,692 bashcolor-0.9.1.dist-info/top_level.txt,sha256=sCt16IKRenYOma9L2QXQShwZzZ5Ub9Ytf_ArmgxOh9w,10 PKbN}HIIbashcolor/__init__.pyPKNQ}H))|bashcolor-0.9.1.dist-info/DESCRIPTION.rstPKNQ}H#99* bashcolor-0.9.1.dist-info/entry_points.txtPKNQ}Hhݴ'. bashcolor-0.9.1.dist-info/metadata.jsonPKNQ}H ''bashcolor-0.9.1.dist-info/top_level.txtPKNQ}H''\\vbashcolor-0.9.1.dist-info/WHEELPKNQ}HT_U%%"bashcolor-0.9.1.dist-info/METADATAPKNQ}Hթ tbashcolor-0.9.1.dist-info/RECORDPK[