Skip to main content

A lighthearted Python package with text modification utilities.

Project description

CI

Text Modifier Package

Built by

Minho Eune

Alejandro Fiestas

Diya Greben

Rehan Gupta

Ani Guduru

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 Program

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

To try the package with the included demo program, run example.py from the project root:

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.

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.0.tar.gz (46.0 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.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for honey_badger_text_modifier-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0564957bf79092efd395945f5263095cbef57458c42eeeb00be1607959f7da7d
MD5 088a021e8b13dd89eb2bdc3cb0f63873
BLAKE2b-256 62d90966b40bef02562d15edc31ff6eaf105de9406081c969d9da3198c4344a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for honey_badger_text_modifier-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ccd98a26d22159dbf6a3648ad90114a515595cb981568c3fb22171307eaa10c
MD5 1a9065cb389046a1b9067885178d2120
BLAKE2b-256 1332dd867806d580ff928a99766d76a49cb8427cd3caf69cc32567556d1e86d2

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