A lighthearted Python package with text modification utilities.
Project description
Text Modifier Package
Built by
Description
The Text Modifier Package is a Python library that provides fun and useful text transformations. It allows developers to manipulate text in creative ways, such as rendering block-style fonts, encoding and decoding messages, removing vowels, and reversing strings.
Configuration
This project does not require any environment variables or external configuration.
No .env file or database setup is needed to run the package.
Features
Block Font
The main function, block_text(text, scale=1), takes a string and returns a block-font version of that text. Input is converted to uppercase before rendering, so lowercase and uppercase letters behave the same.
Supported characters:
A-Z0-9- space
!?.,
The scale argument increases the size of the rendered output. Larger scale values make each character wider and taller.
Example Usage:
from textmodifier import block_text
print(block_text("Hi!"))
# Output:
# # # ##### #
# # # # #
# ##### # #
# # # #
# # # ##### #
Known limitation
Very long input strings or large scale values can produce extremely large outputs. Since the function builds the full rendered string in memory before returning it, performance or memory issues may happen for oversized output.
Fixed Length Encode
The function fixed_length_encode(text, only_code=False, ignore_case=False, bit_style=("1", "0")) encodes text into a binary-style string.
Arguments:
-
text(str): The text to encode. -
only_code(bool): If True, returns only the encoded string without the character mapping (default is False). -
ignore_case(bool): If True, ignores capitalization (default is False). -
bit_style(tuple): Allows custom characters to represent "1" and "0".
Example Usage:
from textmodifier import fixed_length_encode
encoded_text, mapping = fixed_length_encode("Hello", False, False,("👾", "🦭"))
print(encoded_text)
# Output: 🦭🦭🦭👾👾🦭👾🦭👾👾
print(mapping)
#Output: {'H': '🦭🦭', 'e': '🦭👾', 'l': '👾🦭', 'o': '👾👾'}
print(fixed_length_encode("Hello World", True))
# Output: 001100101101110000010110111101011
Fixed Length Decode
The function fixed_length_decode(encoded_text, mapping) decodes a binary-style text using the provided mapping.
Arguments:
encoded_text(str): The encoded string to decode.mapping(dict): The dictionary mapping original characters to their codes.
Example Usage:
from textmodifier import fixed_length_decode
encoded_text = "FFFTTFTFTT"
mapping = {'H': 'FF', 'e': 'FT', 'l': 'TF', 'o': 'TT'}
print(fixed_length_decode(encoded_text, mapping))
# Output: "Hello"
Remove Vowels
The function remove_vowels(text, remove_y=False) takes a string and returns a new string with all the vowels (a, e, i, o, u) removed.
Arguments:
-
text(str): The input text from which to remove vowels. -
remove_y(bool): If True, the function will also remove the letters 'y' and 'Y' from the text (default is False).
Example Usage:
from textmodifier import remove_vowels
# Default behavior (keeps 'y')
print(remove_vowels("Yellow puppy"))
# Output: "Yllw pppy"
# Modified behavior (removes 'y')
print(remove_vowels("Yellow puppy", remove_y=True))
# Output: "llw ppp"
Reverse Text
The function reverse_text(text) takes a string and returns a new string with all the characters in reverse order (left to right).
Arguments:
text(str): The string to reverse
Behavior
This function works for all characters in a string, including numbers ("5"), letters ("h"), whitespace (" "), and special characters ("!").
Example Usage:
from textmodifier import reverse_text
print(reverse_text("hello")) # Output: "olleh"
How to run unit tests
Simple unit tests are included within the 'test' directory. This project uses pytest. To run the tests:
- Install
pytestinto the virtual environment - Run the tests from the main project directory:
python3 -m pytest. - Tests should not fail. If the tests fail, it means that the production code is behaving differently from the behavior the tests expect.
Install and Try the Package
To install the package with pip, run:
pip install honey-badger-text-modifier
To install the package with pipenv, run:
pipenv install honey-badger-text-modifier
Example Program
A complete example program demonstrating all package functionality is included: View example
To run it:
python example.py
The demo walks through the package functions and also includes an interactive mode.
How to calculate code coverage
To check how much of the codebase is covered by unit tests, run:
python3 -m pytest --cov=.
Continuous integration
This project has a continuous integration workflow that builds and runs unit tests automatically with every pull request of the code to GitHub.
Developer Setup
To contribute or work on the project locally:
-
Install dependencies: pipenv install
-
Activate environment: pipenv shell
-
Run tests: pytest
-
Build package: python -m build
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 honey_badger_text_modifier-0.1.1.tar.gz.
File metadata
- Download URL: honey_badger_text_modifier-0.1.1.tar.gz
- Upload date:
- Size: 46.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fa3cbd7fbe7c45ea9b015a1eb4036890e7ac40ea07e965322ee2c5409a30ae2
|
|
| MD5 |
ab1aae7899ee449bec845476ca16e619
|
|
| BLAKE2b-256 |
b04e32d5cfba0a22147c6c8643ef8e34e26bc2c9a733bdd2d0297c2678824070
|
File details
Details for the file honey_badger_text_modifier-0.1.1-py3-none-any.whl.
File metadata
- Download URL: honey_badger_text_modifier-0.1.1-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44fc39fcc0d13a2f75cc66c21bf3612445d65a1e0e3b718fe90d7103b79b3f30
|
|
| MD5 |
2e5d479692c67afa09493835d1149318
|
|
| BLAKE2b-256 |
f2a5fb7ca05ed64b65106382a15d8d8341111ea16134ba99724e228371bb79e9
|