ColorfulOutput


NameColorfulOutput JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/RasseTheBoy/ColorfulOutput
SummaryAdds colors to your console prints.
upload_time2023-08-07 23:36:57
maintainer
docs_urlNone
authorRasmus Ohert
requires_python>=3.5
licenseMIT License Copyright (c) 2023 Rasse Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python console colors print
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ColorfulOutput
=============

<p align="center">
    <img src="Images/Logo/ColorfulOutputLogo.png" width=500>
</p>

A python library that adds colors to your console prints.

# Author

- [@RasseTheBoy](https://github.com/RasseTheBoy)

# Installation

```bash
pip install ColorfulOutput
# or
pip3 install ColorfulOutput
```

# Usage

The library contains methods that you can use to color your **console** text.  
[**These "colored" strings should only be used for console prints, and not for anything else!**](#known-issues)

```python
import ColorfulOutput as cc

text = cc.HEADER("Hello World!")
print(text)
```

```python
from ColorfulOutput import BLUE, RED

print(BLUE("This is all blue text!"))
print(RED("This is all red text!"))
```

```python
from ColorfulOutput import CYAN, YELLOW, RED, BOLD, UNDERLINE

text = f'{BOLD("Never")} {YELLOW("gonna")} {UNDERLINE("give")} {RED("you")} {CYAN("up")}!'

print(text)
```

# Methods

- `HEADER(text)`
- `BLUE(text)`
- `CYAN(text)`
- `GREEN(text)`
- `YELLOW(text)`
- `RED(text)`
- `BOLD(text)`
- `UNDERLINE(text)`

# Known issues!

## Repr

The methods will return a text string that seems like a normal text to the console, but it is actually a string with special characters that makes the text colored. This means that when you use the `repr()` function, it will return a string with special characters instead of the actual text.

This also means that when you use the `!r` format specifier, it will return a string with special characters instead of the actual text.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

print(repr(clean_text))
# Output: 'Hello World!'

print(f'{clean_text!r}')
# Output: 'Hello World!'

print(repr(color_text))
# Output: '\x1b[94mHello World!\x1b[0m'

print(f'{color_text!r}')
# Output: '\x1b[94mHello World!\x1b[0m'
```

## Writing to files

When you write the colored text to a file, it will write the special characters to the file instead of the actual text.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

with open("file.txt", "w") as file:
    file.write(clean_text)
    file.write(color_text)
```

`file.txt:`
```
Hello World!
Hello World!
```

## Length

The special characters will also be counted as characters when you use the `len()` function.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

print(len(clean_text))
# Output: 12

print(len(color_text))
# Output: 21
```

## Adding multiple colors and styles

When you add multiple colors and styles to a string, it will not work as expected.

```python
from ColorfulOutput import BLUE, BOLD, UNDERLINE

text = BLUE("Hello ")
text += BOLD("World!")

full_text = UNDERLINE(text)

print(full_text)
```

`Console output:`  
![Console output](Images/Other/invalid_output.png)


# Workarounds

The only workaround for most of these issues is to create a "clean" string that only contains the text (as shown in the examples above).  
Then a separate "color" string that contains the text with the colors and styles.

# Future

All of these issues will be fixed in the future, but for now, you will have to use the workarounds.

If you any suggestions or issues, please let me know!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RasseTheBoy/ColorfulOutput",
    "name": "ColorfulOutput",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "python,console,colors,print",
    "author": "Rasmus Ohert",
    "author_email": "Rasmus Ohert <rassemichael@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c5/0d/9f93088d9aface3de206b5d72abf81bbc37f8887d62fa82dd6d172e1f37d/ColorfulOutput-0.0.1.tar.gz",
    "platform": null,
    "description": "ColorfulOutput\r\n=============\r\n\r\n<p align=\"center\">\r\n    <img src=\"Images/Logo/ColorfulOutputLogo.png\" width=500>\r\n</p>\r\n\r\nA python library that adds colors to your console prints.\r\n\r\n# Author\r\n\r\n- [@RasseTheBoy](https://github.com/RasseTheBoy)\r\n\r\n# Installation\r\n\r\n```bash\r\npip install ColorfulOutput\r\n# or\r\npip3 install ColorfulOutput\r\n```\r\n\r\n# Usage\r\n\r\nThe library contains methods that you can use to color your **console** text.  \r\n[**These \"colored\" strings should only be used for console prints, and not for anything else!**](#known-issues)\r\n\r\n```python\r\nimport ColorfulOutput as cc\r\n\r\ntext = cc.HEADER(\"Hello World!\")\r\nprint(text)\r\n```\r\n\r\n```python\r\nfrom ColorfulOutput import BLUE, RED\r\n\r\nprint(BLUE(\"This is all blue text!\"))\r\nprint(RED(\"This is all red text!\"))\r\n```\r\n\r\n```python\r\nfrom ColorfulOutput import CYAN, YELLOW, RED, BOLD, UNDERLINE\r\n\r\ntext = f'{BOLD(\"Never\")} {YELLOW(\"gonna\")} {UNDERLINE(\"give\")} {RED(\"you\")} {CYAN(\"up\")}!'\r\n\r\nprint(text)\r\n```\r\n\r\n# Methods\r\n\r\n- `HEADER(text)`\r\n- `BLUE(text)`\r\n- `CYAN(text)`\r\n- `GREEN(text)`\r\n- `YELLOW(text)`\r\n- `RED(text)`\r\n- `BOLD(text)`\r\n- `UNDERLINE(text)`\r\n\r\n# Known issues!\r\n\r\n## Repr\r\n\r\nThe methods will return a text string that seems like a normal text to the console, but it is actually a string with special characters that makes the text colored. This means that when you use the `repr()` function, it will return a string with special characters instead of the actual text.\r\n\r\nThis also means that when you use the `!r` format specifier, it will return a string with special characters instead of the actual text.\r\n\r\n```python\r\nfrom ColorfulOutput import BLUE\r\n\r\nclean_text = \"Hello World!\"\r\ncolor_text = BLUE(clean_text)\r\n\r\nprint(repr(clean_text))\r\n# Output: 'Hello World!'\r\n\r\nprint(f'{clean_text!r}')\r\n# Output: 'Hello World!'\r\n\r\nprint(repr(color_text))\r\n# Output: '\\x1b[94mHello World!\\x1b[0m'\r\n\r\nprint(f'{color_text!r}')\r\n# Output: '\\x1b[94mHello World!\\x1b[0m'\r\n```\r\n\r\n## Writing to files\r\n\r\nWhen you write the colored text to a file, it will write the special characters to the file instead of the actual text.\r\n\r\n```python\r\nfrom ColorfulOutput import BLUE\r\n\r\nclean_text = \"Hello World!\"\r\ncolor_text = BLUE(clean_text)\r\n\r\nwith open(\"file.txt\", \"w\") as file:\r\n    file.write(clean_text)\r\n    file.write(color_text)\r\n```\r\n\r\n`file.txt:`\r\n```\r\nHello World!\r\n\u001b[94mHello World!\u001b[0m\r\n```\r\n\r\n## Length\r\n\r\nThe special characters will also be counted as characters when you use the `len()` function.\r\n\r\n```python\r\nfrom ColorfulOutput import BLUE\r\n\r\nclean_text = \"Hello World!\"\r\ncolor_text = BLUE(clean_text)\r\n\r\nprint(len(clean_text))\r\n# Output: 12\r\n\r\nprint(len(color_text))\r\n# Output: 21\r\n```\r\n\r\n## Adding multiple colors and styles\r\n\r\nWhen you add multiple colors and styles to a string, it will not work as expected.\r\n\r\n```python\r\nfrom ColorfulOutput import BLUE, BOLD, UNDERLINE\r\n\r\ntext = BLUE(\"Hello \")\r\ntext += BOLD(\"World!\")\r\n\r\nfull_text = UNDERLINE(text)\r\n\r\nprint(full_text)\r\n```\r\n\r\n`Console output:`  \r\n![Console output](Images/Other/invalid_output.png)\r\n\r\n\r\n# Workarounds\r\n\r\nThe only workaround for most of these issues is to create a \"clean\" string that only contains the text (as shown in the examples above).  \r\nThen a separate \"color\" string that contains the text with the colors and styles.\r\n\r\n# Future\r\n\r\nAll of these issues will be fixed in the future, but for now, you will have to use the workarounds.\r\n\r\nIf you any suggestions or issues, please let me know!\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Rasse  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Adds colors to your console prints.",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/RasseTheBoy/ColorfulOutput",
        "Repository": "https://github.com/RasseTheBoy/ColorfulOutput"
    },
    "split_keywords": [
        "python",
        "console",
        "colors",
        "print"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b374fa86c125b1fa182375e95a46e44a7dd149978e77ecdebd73912eeffcaaf3",
                "md5": "6ecba451dc10ebbc45a56a3b2d293a6b",
                "sha256": "5a8bda039ce5ed653ccabd4bcfbd6701c0a8d4261be305880b997154b373f699"
            },
            "downloads": -1,
            "filename": "ColorfulOutput-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ecba451dc10ebbc45a56a3b2d293a6b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 4858,
            "upload_time": "2023-08-07T23:36:55",
            "upload_time_iso_8601": "2023-08-07T23:36:55.868096Z",
            "url": "https://files.pythonhosted.org/packages/b3/74/fa86c125b1fa182375e95a46e44a7dd149978e77ecdebd73912eeffcaaf3/ColorfulOutput-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c50d9f93088d9aface3de206b5d72abf81bbc37f8887d62fa82dd6d172e1f37d",
                "md5": "c78582233f63f9c7fd95f96244d62861",
                "sha256": "5732e484e26b2d8f1b7310c9f0552ab69d64f8131998564cfe224938f56e0b9f"
            },
            "downloads": -1,
            "filename": "ColorfulOutput-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c78582233f63f9c7fd95f96244d62861",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 4354,
            "upload_time": "2023-08-07T23:36:57",
            "upload_time_iso_8601": "2023-08-07T23:36:57.103048Z",
            "url": "https://files.pythonhosted.org/packages/c5/0d/9f93088d9aface3de206b5d72abf81bbc37f8887d62fa82dd6d172e1f37d/ColorfulOutput-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-07 23:36:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RasseTheBoy",
    "github_project": "ColorfulOutput",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "colorfuloutput"
}
        
Elapsed time: 0.10072s