A text-manipulator tool for cases and types.
Project description
🧩 texton ⇄ 🐍🔁🛠️
**texton** module provides you many common & uncommon cases in python, including some text manipulation functions & conversions
Features
- Functions for most popular cases.
- Text manipulation functions.
- Pure python 3.10 to 3.14+.
- No dependencies.
- custom text and background colouring.
- Binary conversion.
- Hexadecimal notation & decimal code point unicode conversion.
- Conversion between: cases, binary, unicode.
Supported Cases
The available cases in texton are:
| case | view |
|---|---|
| mocking | MoCkInG CaSe |
| camel | camel Case |
| pascal | PascalCase |
| snake | snake_case |
| kebab | kebab-case |
| cobol | COBOL-CASE |
| constant | CONSTANT_CASE |
| train | Train-Case |
Aliases
some cases have alias names:
| name | alias |
|---|---|
| constant | upper_snake |
| constant | const |
Manipulative functions
Pytext also features various manipulative functions, which includes:
| function | description |
|---|---|
| convert(text, type, to) | convert text to to |
| binary(text) | Represent text in binary |
| unicodify(text, hexa) | Return text in unicode |
| color(text, color, bgc, style) | Colors text |
🧰 Installation
pip install texton
Usage
Basic Usage
>>> from texton import reverse, pascal, convert
>>> reverse("Hello world", foreach=True)
'dlrow olleH'
>>> pascal("foo bar baz")
'Foo Bar Baz'
>>> convert("MAX_SPEED", type_="constant", to="train")
'Max-Speed'
Case conversion
all the formats, cases, types in texton are collected in one function: convert:
>>> from texton import convert
>>> convert(
... "01001000 01100001 01100011 01101011 01100101 01110010",
... type_="binary",
... to="mocking"
... )
'HaCkEr'
>>> convert(
... text="0x0048 0x0069 0x0021 0x0021 0x0021",
... type_="unicode",
... to="string"
... )
'Hi!!!'
Unicode support (Implemented)
Unicode is greatly supported, as you can use any function on any non-ASCII Characters:
>>> from texton import reverse
>>> reverse("أهلا", foreach=True) # non-ASCII Characters (Arabic)
'الهأ'
And the unicodify function in texton, can assist in converting to either Unicode Hexadecimal Code Points (0xXXXX), or Decimal Code Points (NNN)
Important notes
-
The color function, may fail to do it's job in some console environments.
-
Although you can use any unicode character, sometimes it's seemingless to use them as some cases doesn't exist in other writing systems:
>>> from texton import camel
>>> camel("谢谢") # Chinese (non-ASCII)
'谢谢' # No change (seemless)
- The binary function represents only string datatypes (
str), thus any other type given is internally converted to string.
>>> from texton import binary
>>> binary(5) # non-string
'00110101'
>>> binary("5")
'00110101'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file texton-1.0.0.tar.gz.
File metadata
- Download URL: texton-1.0.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac84452877a78921659fbba66dfd65219ca8d5d18199939ab1d55285927267ba
|
|
| MD5 |
42e1e3142386df5ac05c29bee4c0b77d
|
|
| BLAKE2b-256 |
afcbb306c939aef8994fcb2331838e4a5398ef46005fc62a888da50b7bf25a0b
|
File details
Details for the file texton-1.0.0-py3-none-any.whl.
File metadata
- Download URL: texton-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0723e2feed829838f7aaa192e9da9ba0f5d9897158242b4c1f737928fe8047e
|
|
| MD5 |
0cf5fc357588f2168bf9cbb784d4ecdc
|
|
| BLAKE2b-256 |
1662ec061d37069146f6267d5d097a7fcf663b889a602eaca361957df131d346
|