Lorem ipsum generator
Project description
Lorem ipsum generator
- Installation
- Usage
- Testing
In publishing and graphic design, lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content.
The lorem module provides a generic access to generating the lorem ipsum
text from its very original text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Installation
Note that the
loremmodule only supports Python versions since 3.3 🐍
Simply run the following to install the current version from PyPI:
pip install python-lorem
Or install the latest version from the git repository:
git clone https://github.com/JarryShaw/lorem.git
cd lorem
pip install -e .
# and to update at any time
git pull
Usage
Usage of the lorem module is rather simple. Depending on your needs, the
lorem module provides generation of words, sentences, and
paragraphs.
Get random words
The lorem module provides two different ways for getting random words.
-
def word(count=1, func=None, args=[], kwargs={}) -> Iterable[str]: ...
Generate a list of random words.
>>> list(word(count=3)) ['labore', 'tempor', 'commodo'] >>> list(word(count=3, func='capitalize')) ['Ea', 'Lorem', 'Do'] >>> list(word(count=3, func=lambda s: s.upper())) ['UT', 'AMET', 'EXCEPTEUR']
-
Args:
-
count--intNumber of random words.
default:
1 -
func--Optional[Union[str, Callable[[str], str]]]Filter function. It can be an attribute name of
str, or a customised function that takes the originalstrand returns the modifiedstr.default:
None -
args--List[str]Additional positional arguments for
func.default:
[] -
kwargs--Dict[str, Any]Additional keyword arguments for
func.default:
{}
-
-
Returns:
Iterable[str]-- random words generator
-
-
def get_word(count=1, sep=' ', func=None, args=[], kwargs={}) -> str: ...
Return random words.
>>> get_word(count=3) 'anim voluptate non' >>> get_word(count=3, func='capitalize') 'Non Labore Ut' >>> get_word(count=3, func=lambda s: s.upper()) 'NISI TEMPOR CILLUM'
-
Args:
-
count--Union[int, Tuple[int]]Number of random words. To generate random number of words, supply a 2-element tuple of
int, the function will userandom.randintto choose a random integer as the number of random words.default:
1 -
sep--strSeperator between each word.
default:
' ' -
func--Optional[Union[str, Callable[[str], str]]]Filter function. It can be a function name of
str, or a customised function that takes the originalstrand returns the modifiedstr.default:
None -
args--List[str]Additional positional arguments for
func.default:
[] -
kwargs--Dict[str, Any]Additional keyword arguments for
func.default:
{}
-
-
Returns:
str-- random words
-
Get random sentences
The lorem module provides two different ways for getting random sentences.
-
def sentence(count=1, comma=(0, 2), word_range=(4, 8)) -> Iterable[str]: ...
Generate a list of random sentences.
>>> list(sentence()) ['Aute irure et commodo sunt do duis dolor.']
-
Args:
-
count--intNumber of random sentences.
default:
1 -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8)
-
-
Returns:
Iterable[str]-- random sentence generator
-
-
def get_sentence(count=1, comma=(0, 2), word_range=(4, 8), sep=' ') -> Union[str]: ...
Return random sentences.
>>> get_sentence() 'Nostrud laboris lorem minim sit culpa, aliqua nostrud in amet, sint pariatur eiusmod esse.'
-
Args:
-
count--Union[int, Tuple[int]]Number of random sentences. To generate random number of sentences, supply a 2-element tuple of
int, the function will userandom.randintto choose a random integer as the number of random sentences.default:
1 -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8) -
sep--strSeperator between each sentence.
default:
' '
-
-
Returns:
str-- random sentences
-
Get random paragraphs
The lorem module provides two different ways for getting random paragraphs.
-
def paragraph(count=1, comma=(0, 2), word_range=(4, 8), sentence_range=(5, 10)) -> Iterable[str]: ...
Generate a list of random paragraphs.
>>> list(paragraph()) ['Aute sint et cupidatat aliquip. Non exercitation est aliquip voluptate ' 'fugiat, reprehenderit ad occaecat laboris velit consequat. Magna enim ' 'deserunt aute laborum fugiat exercitation. Aliqua ex sunt fugiat in ' 'magna voluptate. Elit nisi exercitation nostrud. Magna proident et ' 'fugiat eiusmod cupidatat fugiat, sit culpa fugiat non ea eu ' 'reprehenderit elit. Proident mollit mollit ut cillum. Nostrud voluptate ' 'aliquip cupidatat anim.']
-
Args:
-
count--intNumber of random paragraphs.
default:
1 -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8) -
sentence_range--Tuple[int]Random range for number of sentences in each paragraph. The function will use
random.randintto choose a random integer as the number of sentences.default:
(5, 10)
-
-
Returns:
Iterable[str]-- random paragraph generator
-
-
def get_paragraph(count=1, comma=(0, 2), word_range=(4, 8), sentence_range=(5, 10)) -> Union[str]: ...
Return random paragraphs.
>>> get_paragraph() 'Exercitation magna sunt excepteur irure adipiscing commodo duis. Est ' 'ipsum qui deserunt, deserunt nostrud reprehenderit esse. Do velit ' 'est in velit sed. Sunt officia officia lorem. Commodo lorem ' 'exercitation veniam officia pariatur velit. Deserunt deserunt sed ' 'consequat laborum consequat dolor. Et consectetur irure sint elit tempor,' ' est minim nisi eiusmod id excepteur. Minim cillum veniam sed aliquip ' 'anim sit, pariatur nostrud ex cillum laboris laborum. Laborum ullamco ' 'mollit elit. Amet id incididunt ipsum sed.'
-
Args:
-
count--intNumber of random paragraphs. To generate random number of paragraphs, supply a 2-element tuple of
int, the function will userandom.randintto choose a random integer as the number of random paragraphs.default:
1 -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8) -
sentence_range--Tuple[int]Random range for number of sentences in each paragraph. The function will use
random.randintto choose a random integer as the number of sentences.default:
(5, 10) -
sep--strSeperator between each paragraph.
default:
' '
-
-
Returns:
str-- random paragraphs
-
Internal APIs
Following are internal APIs for the lorem module.
-
_TEXT: Tuple[str] = ('ad', 'adipiscing', 'aliqua', 'aliquip', 'amet', 'anim', 'aute', 'cillum', 'commodo', 'consectetur', 'consequat', 'culpa', 'cupidatat', 'deserunt', 'do', 'dolor', 'dolore', 'duis', 'ea', 'eiusmod', 'elit', 'enim', 'esse', 'est', 'et', 'eu', 'ex', 'excepteur', 'exercitation', 'fugiat', 'id', 'in', 'incididunt', 'ipsum', 'irure', 'labore', 'laboris', 'laborum', 'lorem', 'magna', 'minim', 'mollit', 'nisi', 'non', 'nostrud', 'nulla', 'occaecat', 'officia', 'pariatur', 'proident', 'qui', 'quis', 'reprehenderit', 'sed', 'sint', 'sit', 'sunt', 'tempor', 'ullamco', 'ut', 'velit', 'veniam', 'voluptate')
Original lorem ipsum text pool.
-
def _gen_pool(dupe=1) -> Iterable[str]: ...
Generate word pool.
-
Args:
-
dupe--intDuplication to generate the word pool.
default:
1
-
-
Returns
Iterable[str]-- an infinite loop word pool
-
-
def _gen_word(pool, func, args=[], kwargs={}) -> str: ...
Generate random word.
-
Args:
-
pool--Iterable[str]Word pool, returned by
_gen_pool. -
func--Optional[Union[str, Callable[[str], str]]]Filter function. It can be an attribute name of
str, or a customised function that takes the originalstrand returns the modifiedstr. -
args--List[str]Additional positional arguments for
func.default:
[] -
kwargs--Dict[str, Any]Additional keyword arguments for
func.default:
{}
-
-
Returns:
str-- random word
-
-
def _gen_sentence(pool, comma, word_range) -> str: ...
Generate random sentence.
-
Args:
-
pool--Iterable[str]Word pool, returned by
_gen_pool. -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8)
-
-
Returns:
str-- random sentence
-
-
def _gen_paragraph(pool, comma, word_range, sentence_range) -> str: ...
Generate random paragraph.
-
Args:
-
pool--Iterable[str]Word pool, returned by
_gen_pool. -
comma--Tuple[int]Random range for number of commas. The function will use
random.randintto choose a random integer as the number of commas.default:
(0, 2) -
word_range--Tuple[int]Random range for number of words in each sentence. The function will use
random.randintto choose a random integer as the number of words.default:
(4, 8) -
sentence_range--Tuple[int]Random range for number of sentences in each paragraph. The function will use
random.randintto choose a random integer as the number of sentences.default:
(5, 10)
-
-
Returns:
str-- random paragraph
-
Testing
The lorem module utilised unittest.mock to patch the builtin functions
from random module. Test cases can be found in test.py.
Contributions are welcome.
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 python-lorem-0.1.0rc1.tar.gz.
File metadata
- Download URL: python-lorem-0.1.0rc1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0e384f12691acd711fb9babc96a1717c7dcbaaee5b1588e04ebbc2ef5460d2
|
|
| MD5 |
e0c4c8e87adfca0d58267c4dfe0a8170
|
|
| BLAKE2b-256 |
33f6d81f816bb1fda8431ddb2e1f195c5a1c6c8e2f4658b1f59bf61981a67d6c
|
File details
Details for the file python_lorem-0.1.0rc1-py3-none-any.whl.
File metadata
- Download URL: python_lorem-0.1.0rc1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3297816fab508e24bced4eea823e81ed5a17a8b5fb417cfd8cfce98dae7a80d6
|
|
| MD5 |
2e4197d1f586ec9b10d4af9eb3f32b85
|
|
| BLAKE2b-256 |
64911becfada4034dcac30ed10ed76df11d25c015315033d8ae7d19c29b497ee
|