{"id":27076227,"url":"https://github.com/aidinhamedi/python-color-print-v2","last_synced_at":"2025-04-06T00:29:02.318Z","repository":{"id":264875254,"uuid":"707720416","full_name":"AidinHamedi/Python-color-print-V2","owner":"AidinHamedi","description":"A simple and user friendly way to print colored text to the console.","archived":false,"fork":false,"pushed_at":"2023-10-20T14:14:02.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-26T15:50:20.271Z","etag":null,"topics":["color","colorfu","colorprint","print","python","python3","regular-expression"],"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/AidinHamedi.png","metadata":{"files":{"readme":"README.md","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":"2023-10-20T14:05:25.000Z","updated_at":"2023-12-31T07:24:56.000Z","dependencies_parsed_at":"2024-11-26T15:50:21.972Z","dependency_job_id":"20718638-707e-44d0-a304-9fe196fb0905","html_url":"https://github.com/AidinHamedi/Python-color-print-V2","commit_stats":null,"previous_names":["aidinhamedi/python-color-print-v2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-color-print-V2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-color-print-V2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-color-print-V2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidinHamedi%2FPython-color-print-V2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AidinHamedi","download_url":"https://codeload.github.com/AidinHamedi/Python-color-print-V2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419616,"owners_count":20936009,"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","colorfu","colorprint","print","python","python3","regular-expression"],"created_at":"2025-04-06T00:29:01.780Z","updated_at":"2025-04-06T00:29:02.313Z","avatar_url":"https://github.com/AidinHamedi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python-color-print-V2\n![Python](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge\u0026logo=python\u0026logoColor=blue)\n\nA Python function to print colored text to the console using advanced terminal colors.\n\n## Function Signature\n```python\ndef print_Color(Input: str, print_END: str = '\\n', start_char: str = '\u003c', end_char: str = '\u003e'):\n```\n\n## Parameters\n- `Input` (str): The input string to be printed. '\u003ccolor\u003e' is used to specify the color of the following text.\n- `print_END` (str): The string appended after the final output. Default is '\\\\n'.\n- `start_char` (str): The character used as the start of the color specifier. Default is '\u003c'.\n- `end_char` (str): The character used as the end of the color specifier. Default is '\u003e'.\n\n## Usage\nyou can print a string in color. For example:\n```python\nprint_Color('\u003cgreen\u003eHello, World!')\n```\nThis will print 'Hello, World!' in green.\n\nOr like:\n```python\nprint_Color('hello \u003cred\u003ehello in red \u003cgreen\u003ehello in green')\n```\n\n## Special Characters\nThe '\u003c\u003e' characters are used as separators for different parts of the string that need to be printed in different colors when using advanced mode.\n\n## Code snippet\n```python\nimport re\n\ndef print_Color(Input: str, print_END: str = '\\n', start_char: str = '\u003c', end_char: str = '\u003e'):\n    \"\"\"\n    Prints colored text to the console using advanced terminal colors.\n\n    Args:\n        Input (str): The input string to be printed. '\u003ccolor\u003e' is used to specify the color of the following text.\n        print_END (str): The string appended after the final output. Default is '\\\\n'.\n        start_char (str): The character used as the start of the color specifier. Default is '\u003c'.\n        end_char (str): The character used as the end of the color specifier. Default is '\u003e'.\n\n    Examples:\n    ~~~python\n        print_Color('Hello, World!') \n        # Prints 'Hello, World!' in normal color.\n\n        print_Color('\u003cred\u003eHello in red\u003cgreen\u003e Hello in green') \n        # Prints 'Hello in red' in red and 'Hello in green' in green.\n\n        print_Color('~red!Hello in red', start_char='~', end_char='!') \n        # Prints 'Hello, World!' in normal color.\n\n    Note:\n        If an invalid color is provided, an error message will be printed.\n    \"\"\"\n    color_code = {\n        'black': '\\x1b[0;30m',\n        'red': '\\x1b[0;31m',\n        'green': '\\x1b[0;32m',\n        'yellow': '\\x1b[0;33m',\n        'blue': '\\x1b[0;34m',\n        'magenta': '\\x1b[0;35m',\n        'cyan': '\\x1b[0;36m',\n        'white': '\\x1b[0;37m',\n        'normal': '\\x1b[0m',\n        'bg_black': '\\x1b[40m',\n        'bg_red': '\\x1b[41m',\n        'bg_green': '\\x1b[42m',\n        'bg_yellow': '\\x1b[43m',\n        'bg_blue': '\\x1b[44m',\n        'bg_magenta': '\\x1b[45m',\n        'bg_cyan': '\\x1b[46m',\n        'bg_white': '\\x1b[47m',\n        'bg_normal': '\\x1b[49m',\n        'light_gray': '\\x1b[0;90m',\n        'light_red': '\\x1b[0;91m',\n        'light_green': '\\x1b[0;92m',\n        'light_yellow': '\\x1b[0;93m',\n        'light_blue': '\\x1b[0;94m',\n        'light_magenta': '\\x1b[0;95m',\n        'light_cyan': '\\x1b[0;96m',\n        'light_white': '\\x1b[0;97m',\n        'bg_light_gray': '\\x1b[0;100m',\n        'bg_light_red': '\\x1b[0;101m',\n        'bg_light_green': '\\x1b[0;102m',\n        'bg_light_yellow': '\\x1b[0;103m',\n        'bg_light_blue': '\\x1b[0;104m',\n        'bg_light_magenta': '\\x1b[0;105m',\n        'bg_light_cyan': '\\x1b[0;106m',\n        'bg_light_white': '\\x1b[0;107m'\n    }\n    pattern = re.escape(start_char) + r'([^' + re.escape(end_char) + r']*)' + re.escape(end_char)\n    substrings = re.split(pattern, Input)\n    current_color = 'normal'\n    for i, sub_str in enumerate(substrings):\n        if i % 2 == 0:\n            print(color_code[current_color] + sub_str + color_code['normal'], end='')\n            current_color = 'normal'\n        else:\n            color = sub_str.strip()\n            if color in color_code:\n                current_color = color\n            else:\n                print(f\"\\n[print_Color] ERROR: Invalid color!!! The input color: '{color}'\")\n    print('', end=print_END)\n```\n\n## Supported Colors\n#### you can use the key word like 'black' and... to set the text color.\n~~~\n'black': '\\x1b[0;30m',\n'red': '\\x1b[0;31m',\n'green': '\\x1b[0;32m',\n'yellow': '\\x1b[0;33m',\n'blue': '\\x1b[0;34m',\n'magenta': '\\x1b[0;35m',\n'cyan': '\\x1b[0;36m',\n'white': '\\x1b[0;37m',\n'normal': '\\x1b[0m',\n'bg_black': '\\x1b[40m',\n'bg_red': '\\x1b[41m',\n'bg_green': '\\x1b[42m',\n'bg_yellow': '\\x1b[43m',\n'bg_blue': '\\x1b[44m',\n'bg_magenta': '\\x1b[45m',\n'bg_cyan': '\\x1b[46m',\n'bg_white': '\\x1b[47m',\n'bg_normal': '\\x1b[49m',\n'light_gray': '\\x1b[0;90m',\n'light_red': '\\x1b[0;91m',\n'light_green': '\\x1b[0;92m',\n'light_yellow': '\\x1b[0;93m',\n'light_blue': '\\x1b[0;94m',\n'light_magenta': '\\x1b[0;95m',\n'light_cyan': '\\x1b[0;96m',\n'light_white': '\\x1b[0;97m',\n'bg_light_gray': '\\x1b[0;100m',\n'bg_light_red': '\\x1b[0;101m',\n'bg_light_green': '\\x1b[0;102m',\n'bg_light_yellow': '\\x1b[0;103m',\n'bg_light_blue': '\\x1b[0;104m',\n'bg_light_magenta': '\\x1b[0;105m',\n'bg_light_cyan': '\\x1b[0;106m',\n'bg_light_white': '\\x1b[0;107m',\n'underline': '\\x1b[4m',\n'bold': '\\x1b[1m',\n'blink': '\\x1b[5m'\n~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidinhamedi%2Fpython-color-print-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidinhamedi%2Fpython-color-print-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidinhamedi%2Fpython-color-print-v2/lists"}