colorer


Namecolorer JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/ALhorm/colorer
SummaryA simple and handy library for coloring strings.
upload_time2023-01-07 17:40:01
maintainer
docs_urlNone
authorALhorm
requires_python>=3.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Getting started

**Installation**:
- Installation with pip:
    ```sh
    $ pip install colorer
    ```

- Installation with git:
    ```sh
    $ git clone https://github.com/ALhorm/colorer.git
    $ cd colorer
    $ python setup.py install
    ```

# Usage

<b>Colorer</b> uses <i>ANSI Escape Sequences</i> for line coloring and supports both color schemes (16 and 256 colors). The description of the text style is set in the line where your text is written. It is important to note that more than one coloring cannot be used for one line. Let's take a look at an example:

```py
from colorer import string

text = string("(( style=bold, fore=green, back=purple )) This is test text", True)

print(text)
```

In this example, the colorer will make the text <b>bold</b>, the text itself will be <b>green</b>, and the background <b>purple</b>. Also, the second parameter, which in this example is set to <b>True</b>, is responsible for removing extra spaces in the text. If it is equal to <b>False</b>, the spaces between the text and the description of the style of this text will be remained, and if the parameter is equal to <b>True</b>, the spaces will be removed. In this case, the entire line will be changed. But you can also color only part of the string:

```py
from colorer import string

text = string("This (( style=italic, fore=yellow, back=none )) is test (( end )) text", True)

print(text)
```

In this example, only part of the text will be colored, namely "<b>is test</b>". The text style will be italic, the text color will be <b>yellow</b>, and the <b>background will remain standard</b>, the word <b>none</b> is responsible for this, which is also available for the fore parameter. And if you want to leave the text style as default, you should set the style parameter to <b>normal</b>. All possible parameter values are shown below:

```py
style = [
  "normal", # standard text
  "bold", # bold text
  "light", # thin text
  "italic", # italic text
  "underlined", # text with underscore
  "blink" # blink text
]

fore = [
  "black",
  "red",
  "green",
  "yellow",
  "blue",
  "purple",
  "cyan",
  "white",
  "none",
  "1-256" # color in numbers, from 1 to 256 (inclusive)
]

back = "same values as fore"
```

As you already understood, the value of the fore and back parameters can be set in <b>numbers</b> (<b>from 1 to 256</b>). It is important to note that only one parameter, either fore or back, can be set in numbers. Moreover, only the parameter to which you set the value in numbers will work.

```py
from colorer import string

text = string("This (( style=underlined, fore=none, back=187 )) is test text", True)

print(text)
```

In this example, we will change the "<b>is test text</b>" part of the string. Namely, we will change the style to <b>underlined</b>, and the background to color <b>187 of the 256 color scheme</b>. This entire scheme is shown below:

<img src="https://raw.githubusercontent.com/ALhorm/colorer/master/img/colors.jpg" alt="256 color scheme">

It is also worth noting that it is not necessary to write text styles, as shown in the example. If you write like this:

```py
text = string("This ((STylE = NORMAL, FORE=none, BaCK=85)) is test ((eNd)) text", True)
```

then nothing will change. But I recommend that you write beautifully, as shown in the previous examples.

# Thank you

Thank you for using the <b>colorer</b> library!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ALhorm/colorer",
    "name": "colorer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "ALhorm",
    "author_email": "gladkoam@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/72/9b/378ff4422ede11cc7d9bef2129504ce4703d1f61f93249c9386c8ff3d16f/colorer-1.0.2.tar.gz",
    "platform": null,
    "description": "# Getting started\r\n\r\n**Installation**:\r\n- Installation with pip:\r\n    ```sh\r\n    $ pip install colorer\r\n    ```\r\n\r\n- Installation with git:\r\n    ```sh\r\n    $ git clone https://github.com/ALhorm/colorer.git\r\n    $ cd colorer\r\n    $ python setup.py install\r\n    ```\r\n\r\n# Usage\r\n\r\n<b>Colorer</b> uses <i>ANSI Escape Sequences</i> for line coloring and supports both color schemes (16 and 256 colors). The description of the text style is set in the line where your text is written. It is important to note that more than one coloring cannot be used for one line. Let's take a look at an example:\r\n\r\n```py\r\nfrom colorer import string\r\n\r\ntext = string(\"(( style=bold, fore=green, back=purple )) This is test text\", True)\r\n\r\nprint(text)\r\n```\r\n\r\nIn this example, the colorer will make the text <b>bold</b>, the text itself will be <b>green</b>, and the background <b>purple</b>. Also, the second parameter, which in this example is set to <b>True</b>, is responsible for removing extra spaces in the text. If it is equal to <b>False</b>, the spaces between the text and the description of the style of this text will be remained, and if the parameter is equal to <b>True</b>, the spaces will be removed. In this case, the entire line will be changed. But you can also color only part of the string:\r\n\r\n```py\r\nfrom colorer import string\r\n\r\ntext = string(\"This (( style=italic, fore=yellow, back=none )) is test (( end )) text\", True)\r\n\r\nprint(text)\r\n```\r\n\r\nIn this example, only part of the text will be colored, namely \"<b>is test</b>\". The text style will be italic, the text color will be <b>yellow</b>, and the <b>background will remain standard</b>, the word <b>none</b> is responsible for this, which is also available for the fore parameter. And if you want to leave the text style as default, you should set the style parameter to <b>normal</b>. All possible parameter values are shown below:\r\n\r\n```py\r\nstyle = [\r\n  \"normal\", # standard text\r\n  \"bold\", # bold text\r\n  \"light\", # thin text\r\n  \"italic\", # italic text\r\n  \"underlined\", # text with underscore\r\n  \"blink\" # blink text\r\n]\r\n\r\nfore = [\r\n  \"black\",\r\n  \"red\",\r\n  \"green\",\r\n  \"yellow\",\r\n  \"blue\",\r\n  \"purple\",\r\n  \"cyan\",\r\n  \"white\",\r\n  \"none\",\r\n  \"1-256\" # color in numbers, from 1 to 256 (inclusive)\r\n]\r\n\r\nback = \"same values as fore\"\r\n```\r\n\r\nAs you already understood, the value of the fore and back parameters can be set in <b>numbers</b> (<b>from 1 to 256</b>). It is important to note that only one parameter, either fore or back, can be set in numbers. Moreover, only the parameter to which you set the value in numbers will work.\r\n\r\n```py\r\nfrom colorer import string\r\n\r\ntext = string(\"This (( style=underlined, fore=none, back=187 )) is test text\", True)\r\n\r\nprint(text)\r\n```\r\n\r\nIn this example, we will change the \"<b>is test text</b>\" part of the string. Namely, we will change the style to <b>underlined</b>, and the background to color <b>187 of the 256 color scheme</b>. This entire scheme is shown below:\r\n\r\n<img src=\"https://raw.githubusercontent.com/ALhorm/colorer/master/img/colors.jpg\" alt=\"256 color scheme\">\r\n\r\nIt is also worth noting that it is not necessary to write text styles, as shown in the example. If you write like this:\r\n\r\n```py\r\ntext = string(\"This ((STylE = NORMAL, FORE=none, BaCK=85)) is test ((eNd)) text\", True)\r\n```\r\n\r\nthen nothing will change. But I recommend that you write beautifully, as shown in the previous examples.\r\n\r\n# Thank you\r\n\r\nThank you for using the <b>colorer</b> library!\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A simple and handy library for coloring strings.",
    "version": "1.0.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c8e7e80c80bd8daad042d5c9f43fe70eb23c8f3aab1b8dfa0eaab33fa02979b5",
                "md5": "2b8e5243427a5c83c3e162a9dbad867d",
                "sha256": "172b99721c2bab10d957c72969a95ccf69d50f8bf11cb443cfcb178ce46b1149"
            },
            "downloads": -1,
            "filename": "colorer-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2b8e5243427a5c83c3e162a9dbad867d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 4749,
            "upload_time": "2023-01-07T17:39:59",
            "upload_time_iso_8601": "2023-01-07T17:39:59.386680Z",
            "url": "https://files.pythonhosted.org/packages/c8/e7/e80c80bd8daad042d5c9f43fe70eb23c8f3aab1b8dfa0eaab33fa02979b5/colorer-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "729b378ff4422ede11cc7d9bef2129504ce4703d1f61f93249c9386c8ff3d16f",
                "md5": "e02c5df0cc35fdc1a2f20e9f39f3168a",
                "sha256": "6d0b90dcae63f7a7f45b8cb1bbe4b1685ecb6c58f68ceb8a575565aceecd1d5d"
            },
            "downloads": -1,
            "filename": "colorer-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e02c5df0cc35fdc1a2f20e9f39f3168a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 4321,
            "upload_time": "2023-01-07T17:40:01",
            "upload_time_iso_8601": "2023-01-07T17:40:01.188187Z",
            "url": "https://files.pythonhosted.org/packages/72/9b/378ff4422ede11cc7d9bef2129504ce4703d1f61f93249c9386c8ff3d16f/colorer-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-07 17:40:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ALhorm",
    "github_project": "colorer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "colorer"
}
        
Elapsed time: 0.06063s