Skip to main content

Generate Lorem Ipsum placeholder text via CLI or Python API

Project description

lorem_gen

lorem_gen is a lightweight Python package and command-line tool that generates Lorem Ipsum placeholder text. It supports generating a specified number of words, sentences, or paragraphs. This package can be used both as a CLI and as an importable library in other Python projects.

Features

  • Generate a custom number of Lorem Ipsum words, sentences, or paragraphs.
  • Simple, dependency-free implementation (built-in Python standard library only).
  • CLI interface via the genrqtor command.
  • Programmatic API through the LoremGenerator class.

Installation

Install lorem_gen in editable (development) mode or as a regular package. It requires Python 3.8 or newer.

# (Optional) Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Upgrade packaging tools
pip install --upgrade pip setuptools wheel

# Install lorem_gen in editable mode
pip install -e .

After installation, the package is importable via import lorem_gen and the CLI command genrqtor is registered on your PATH.

Usage

Command-Line Interface (CLI)

The tool is exposed as genrqtor. Run the following for help:

genrqtor --help

Output:

usage: genrqtor [-h] [--words WORDS | --sentences SENTENCES | --paragraphs PARAGRAPHS]

Generate Lorem Ipsum text.

optional arguments:
  -h, --help           show this help message and exit
  --words WORDS        Number of words to generate (e.g., --words 50).
  --sentences SENTENCES
                       Number of sentences to generate (e.g., --sentences 5).
  --paragraphs PARAGRAPHS
                       Number of paragraphs to generate (e.g., --paragraphs 2).

Examples:

  • Generate 50 words of Lorem Ipsum:

    genrqtor --words 50
    
  • Generate 5 sentences of Lorem Ipsum:

    genrqtor --sentences 5
    
  • Generate 2 paragraphs of Lorem Ipsum:

    genrqtor --paragraphs 2
    
  • Default (no flags) generates a single paragraph:

    genrqtor
    

Programmatic API

You can also use lorem_gen in your own Python code by importing the LoremGenerator class.

from lorem_gen.generator import LoremGenerator

# Generate 20 words:
gen_words = LoremGenerator(words=20)
print(gen_words.generate())

# Generate 3 sentences:
gen_sentences = LoremGenerator(sentences=3)
print(gen_sentences.generate())

# Generate 2 paragraphs:
gen_paragraphs = LoremGenerator(paragraphs=2)
print(gen_paragraphs.generate())

API Reference

  • LoremGenerator(words: int = 0, sentences: int = 0, paragraphs: int = 0)

    • Constructor. Specify exactly one of words, sentences, or paragraphs to control output. If none provided, defaults to 1 paragraph.
  • LoremGenerator.generate() -> str

    • Returns the generated Lorem Ipsum text as a string.
  • --words <int>

    • CLI flag to generate a certain number of words.
  • --sentences <int>

    • CLI flag to generate a certain number of sentences.
  • --paragraphs <int>

    • CLI flag to generate a certain number of paragraphs.

Development & Testing

Running Tests

A basic pytest-based test suite is provided in the tests/ directory. To run tests:

pip install pytest         # If not already installed
pytest

Linting & Formatting

You can add flake8 or other linters to your development dependencies. A sample requirements-dev.txt may include:

pytest>=7.0
flake8>=5.0

Install with:

pip install -r requirements-dev.txt

Then run:

flake8 src/lorem_gen
tests

Contributing

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/my-new-feature.
  3. Make your changes and commit: git commit -am 'Add new feature'.
  4. Push to the branch: git push origin feature/my-new-feature.
  5. Open a Pull Request.

Please follow the existing code style, include tests for new features, and update this README as needed.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

lorem_gen-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

lorem_gen-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lorem_gen-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for lorem_gen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e8a5b66de5318906dfe374888d558004c5f9f79fa30579d158cfa927a5033cf9
MD5 82cd5b1f3fca07719caeb5157d59cf82
BLAKE2b-256 b2c74a4575bc58d73dad8a0e89fd9a49b26135708000e7fe50be5373efa730d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lorem_gen-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for lorem_gen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd549cba2c015994da8d81dff201ff2851aea468d4c9c0fda45f5d18532f717
MD5 e07bf2bf9947a51a83eb52fdef542a99
BLAKE2b-256 be0e11e39df049d1325256b3c1ff5050f51053359c260c0cabb3254d1a1039ff

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