Skip to main content

A lighthearted Python package with text modification utilities.

Project description

CI

Text Modifier Package

PyPI URL

Built by

Minho Eune

Alejandro Fiestas

Diya Greben

Rehan Gupta

Ani Guduru

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-Z
  • 0-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:

  1. Install pytest into the virtual environment
  2. Run the tests from the main project directory: python3 -m pytest.
  3. 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:

  1. Install dependencies: pipenv install

  2. Activate environment: pipenv shell

  3. Run tests: pytest

  4. Build package: python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

honey_badger_text_modifier-0.1.1.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

honey_badger_text_modifier-0.1.1-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file honey_badger_text_modifier-0.1.1.tar.gz.

File metadata

File hashes

Hashes for honey_badger_text_modifier-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6fa3cbd7fbe7c45ea9b015a1eb4036890e7ac40ea07e965322ee2c5409a30ae2
MD5 ab1aae7899ee449bec845476ca16e619
BLAKE2b-256 b04e32d5cfba0a22147c6c8643ef8e34e26bc2c9a733bdd2d0297c2678824070

See more details on using hashes here.

File details

Details for the file honey_badger_text_modifier-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for honey_badger_text_modifier-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44fc39fcc0d13a2f75cc66c21bf3612445d65a1e0e3b718fe90d7103b79b3f30
MD5 2e5d479692c67afa09493835d1149318
BLAKE2b-256 f2a5fb7ca05ed64b65106382a15d8d8341111ea16134ba99724e228371bb79e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page