fortext


Namefortext JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryText stylizer for Python. Mainly useful for CLI output.
upload_time2024-10-28 13:28:30
maintainerNone
docs_urlNone
author4MBL
requires_python>=3.11
licenseMIT License Copyright (c) 2023 4MBL 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
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [fortext](https://4mbl.link/gh/fortext)

Text stylizer for Python. Mainly useful for CLI output.

## Table of Contents

* [Table of Contents](#table-of-contents)
  * [Installation](#installation)
* [Usage](#usage)
  * [Text styling](#text-styling)
  * [Print all styles](#print-all-styles)
  * [Syntax highlighting](#syntax-highlighting)
  * [String permutations](#string-permutations)

### Installation

Use pip to install `fortext`.

```bash
python3 -m pip install --upgrade fortext
```

## Usage

### Text styling

```python
from fortext import style, Bg, Frmt
print(style('Hi, human.', fg='#ff0000'))
print(style('RGB tuple or list also works.', fg=(0, 255, 0)))
print(style('You can also use predefined colors.', bg=Bg.BLACK))
print(style('Want to be bold?.', frmt=[Frmt.BOLD]))

print(
    style('Want to go all in?',
          fg='#ff0000', bg=Bg.BLACK,
          frmt=[Frmt.BOLD, Frmt.UNDERLINE, Frmt.ITALIC]))
```

### Print all styles

```python
from fortext import print_styles_all
print_styles_all()
```

### Syntax highlighting

```python
from fortext import highlight
print(highlight({'somekey': 'somevalue', 'anotherkey': [12.4, True, 23]}))
```

Output:

![syntax highlighting output](./img/syntax_highlighting.png)

### String permutations

```python
from fortext import permutations
for perm in permutations('abc'):
    print(perm)
```

Output:

```text
a
b
c
ab
ac
ba
bc
ca
cb
abc
acb
bac
bca
cab
cba
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fortext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "4MBL",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/45/05/3affd915c66977bb82db335d58f464da6944a24fcccaa440542160b4949f/fortext-1.0.0.tar.gz",
    "platform": null,
    "description": "# [fortext](https://4mbl.link/gh/fortext)\n\nText stylizer for Python. Mainly useful for CLI output.\n\n## Table of Contents\n\n* [Table of Contents](#table-of-contents)\n  * [Installation](#installation)\n* [Usage](#usage)\n  * [Text styling](#text-styling)\n  * [Print all styles](#print-all-styles)\n  * [Syntax highlighting](#syntax-highlighting)\n  * [String permutations](#string-permutations)\n\n### Installation\n\nUse pip to install `fortext`.\n\n```bash\npython3 -m pip install --upgrade fortext\n```\n\n## Usage\n\n### Text styling\n\n```python\nfrom fortext import style, Bg, Frmt\nprint(style('Hi, human.', fg='#ff0000'))\nprint(style('RGB tuple or list also works.', fg=(0, 255, 0)))\nprint(style('You can also use predefined colors.', bg=Bg.BLACK))\nprint(style('Want to be bold?.', frmt=[Frmt.BOLD]))\n\nprint(\n    style('Want to go all in?',\n          fg='#ff0000', bg=Bg.BLACK,\n          frmt=[Frmt.BOLD, Frmt.UNDERLINE, Frmt.ITALIC]))\n```\n\n### Print all styles\n\n```python\nfrom fortext import print_styles_all\nprint_styles_all()\n```\n\n### Syntax highlighting\n\n```python\nfrom fortext import highlight\nprint(highlight({'somekey': 'somevalue', 'anotherkey': [12.4, True, 23]}))\n```\n\nOutput:\n\n![syntax highlighting output](./img/syntax_highlighting.png)\n\n### String permutations\n\n```python\nfrom fortext import permutations\nfor perm in permutations('abc'):\n    print(perm)\n```\n\nOutput:\n\n```text\na\nb\nc\nab\nac\nba\nbc\nca\ncb\nabc\nacb\nbac\nbca\ncab\ncba\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 4MBL  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": "Text stylizer for Python. Mainly useful for CLI output.",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/4mbl/fortext/issues",
        "Homepage": "https://github.com/4mbl/fortext"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0b904018211c9b941f3f45c4072f83b4958a10dabe81ad92a744b38237858a9",
                "md5": "31637a012d24a97fb41ae09aee552075",
                "sha256": "63f78abbf37cd927e943a9e79c2a3da5ff7cec51cc7cd1cb762dcac75ef93aad"
            },
            "downloads": -1,
            "filename": "fortext-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "31637a012d24a97fb41ae09aee552075",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 7281,
            "upload_time": "2024-10-28T13:28:28",
            "upload_time_iso_8601": "2024-10-28T13:28:28.813008Z",
            "url": "https://files.pythonhosted.org/packages/c0/b9/04018211c9b941f3f45c4072f83b4958a10dabe81ad92a744b38237858a9/fortext-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45053affd915c66977bb82db335d58f464da6944a24fcccaa440542160b4949f",
                "md5": "47f0f968fc2aa1def9fc71cf7d855da8",
                "sha256": "d229dc5f1595ef1475b1e99bd9854b18f25af7fdc045124dc341ed966adc8e5f"
            },
            "downloads": -1,
            "filename": "fortext-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "47f0f968fc2aa1def9fc71cf7d855da8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12320,
            "upload_time": "2024-10-28T13:28:30",
            "upload_time_iso_8601": "2024-10-28T13:28:30.304406Z",
            "url": "https://files.pythonhosted.org/packages/45/05/3affd915c66977bb82db335d58f464da6944a24fcccaa440542160b4949f/fortext-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 13:28:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "4mbl",
    "github_project": "fortext",
    "github_not_found": true,
    "lcname": "fortext"
}
        
Elapsed time: 0.43484s