{"id":13815270,"url":"https://github.com/reorx/python-terminal-color","last_synced_at":"2025-06-18T13:41:23.144Z","repository":{"id":141893042,"uuid":"66710486","full_name":"reorx/python-terminal-color","owner":"reorx","description":"Drop-in single file library for printing color in terminal","archived":false,"fork":false,"pushed_at":"2024-04-11T05:50:57.000Z","size":271,"stargazers_count":71,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-01T10:35:08.214Z","etag":null,"topics":["color","python","terminal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reorx.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-27T11:09:24.000Z","updated_at":"2024-08-24T18:18:09.000Z","dependencies_parsed_at":"2024-08-04T04:07:19.432Z","dependency_job_id":"34eb8f66-b2c0-4919-97cc-f67882f3507c","html_url":"https://github.com/reorx/python-terminal-color","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reorx%2Fpython-terminal-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reorx%2Fpython-terminal-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reorx%2Fpython-terminal-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reorx%2Fpython-terminal-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reorx","download_url":"https://codeload.github.com/reorx/python-terminal-color/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223673048,"owners_count":17183618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","python","terminal"],"created_at":"2024-08-04T04:03:14.216Z","updated_at":"2024-11-08T11:01:51.611Z","avatar_url":"https://github.com/reorx.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Python Terminal Color\n=====================\n\n.. image:: screenshot.png\n\nIntroduction\n------------\n\n1. This is a drop-in library for print colorized output in terminal.\n2. It has no pypi package, which means you can't install it through pip.\n3. It is recommended to be used as a submodule of your own project,\n   so that no dependency will be involved.\n4. ``color.py`` is Python 3 only and recommended to choose; ``color_compat.py`` is Python 2/3 compatible, only use it if you still struggle in the Python 2 morass.\n\n\nUsage\n-----\n\nCopy the ``color.py`` file to your project, then:\n\n.. code:: python\n\n    from yourproject import color\n\n    # 8 bit color\n    print(color.red('red') + color.green('green') + color.blue('blue'))\n    print(color.bold(color.yellow('bold yellow')) + color.underline(color.cyan('underline cyan')))\n    print(color.magenta_hl('magenta highlight'))\n\n    # xterm 256 color\n    print(color.bg256('A9D5DE', color.fg256('276F86', 'Info!')))\n    print(color.bg256('E0B4B4', color.fg256('912D2B', 'Warning!')))\n    print(color.hl256('10a3a3', 'Teal'))\n\n\nNote:\n\n1. Every color function receives and returns string, so that the result\n   could be used with any other strings, in any string formatting situation.\n\n2. If you pass a str type string, the color function will return a str.\n   If you pass a bytes type string, the color function will return a bytes.\n\n3. Color functions could be composed together, like put ``red`` into ``bold``,\n   or put ``bg256`` into ``fg256``. ``xxx_hl`` and ``hl256`` are mostly used\n   independently.\n\n\nAPI\n---\n\nfunction ``\u003ccolor_function\u003e(s)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDecorate string with specified color.\n\n``color_function`` is one of below function names:\n\n========  ============  ===========\n Colors    Background    Highlight\n========  ============  ===========\nblack     black_bg      black_hl\nred       red_bg        red_hl\ngreen     green_bg      green_hl\nyellow    yellow_bg     yellow_hl\nblue      blue_bg       blue_hl\nmagenta   magenta_bg    magenta_hl\ncyan      cyan_bg       cyan_hl\nwhite     white_bg      white_hl\n========  ============  ===========\n\nA color function with ``_bg`` suffix means it will set color as background.\nA color function with ``_hl`` suffix means it will set color as background,\nand change the foreground as well to make the word standout.\n\nParameters:\n\n:param str s: The input string\n:return: The decorated string\n:rtype: string\n:raises ValueError: if the message_body exceeds 160 characters\n\nfunction ``\u003cstyle_function\u003e(s)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDecorate string with specified style.\n\n``style_function`` is one of below function names:\n\n- bold\n- italic\n- underline\n- strike\n- blink\n\nArguments and return are the same as ``color_function``.\n\n\nfunction ``\u003c256_color_function\u003e(hexrgb, s)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDecorate string with specified hex rgb color\n\n``256_color_function`` is one of below function names:\n\n- fg256: will set color as foreground.\n- bg256: will set color as background.\n- hl256: will highlight input with the color.\n\nParameters:\n\n:param str hexrgb: The hex rgb color string, accept length 3 and 6. eg: ``555``, ``912D2B``\n:param str s: The input string\n:return: The decorated string\n:rtype: string\n:raises ValueError: If the input string's length not equal to 3 or 6.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freorx%2Fpython-terminal-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freorx%2Fpython-terminal-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freorx%2Fpython-terminal-color/lists"}