loremipsum module¶
-
class
loremipsum.
ParagraphLength
[source]¶ Bases:
object
Constants for the
paragraph_length
parameter in generate()-
OPTIONS
= ['short', 'medium', 'long', 'verylong']¶ List of values for paragraph lengths. Used internally.
-
SHORT
= 0¶
-
MEDIUM
= 1¶
-
LONG
= 2¶
-
VERY_LONG
= 3¶
-
classmethod
get_option
(index)[source]¶ Returns the string value that corresponds to the constants declared in this class. Used internally.
Parameters: index – One of the constants declared in this class ( SHORT
,MEDIUM
,LONG
,VERY_LONG
)Returns: The corresponding string value for the loripsum.net API or None if the index is invalid
-
-
loremipsum.
HTML_OPTIONS
= ['decorate', 'link', 'ul', 'ol', 'dl', 'bq', 'code', 'headers']¶ Valid keys for html_options
-
loremipsum.
generate
(paragraph_count=None, paragraph_length=None, allcaps=False, prude=False, plaintext=True, html_options=None, trailing_newlines=False)[source]¶ Generate Lorem Ipsum placeholder text using the https://loripsum.net API.
Further documentation of parameters can be found at loripsum.net
Parameters: - paragraph_count – (Optional) The number of paragraphs to generate. If unspecified, API defaults to 4
- paragraph_length – (Optional) The average length of a paragraph. Possible
values are declared as attributes in
loremipsum.ParagraphLength
(SHORT
,MEDIUM
,LONG
,VERY_LONG
). If unspecified, API defaults to ‘long’ - allcaps – (Default = False) Use ALL CAPS
- prude – (Default = False) Prude version. From the API documentation: “The original text contains a few instances of words like ‘sex’ or ‘homo’. Personally, we don’t mind, because these are just common latin words meaning ‘six’ and ‘man’. However, some people (or your clients) might be offended by this, so if you select the ‘Prude version’, these words will be censored.”
- plaintext – (Default = True) Return plain text, no HTML
- html_options –
(Default = None) List of html options to specify in request. This will be ignored if plaintext = True. The following options are accepted
- ’decorate’ - Add bold, italic and marked text.
- ’link’- Add links.
- ’ul’ - Add unordered lists.
- ’ol’ - Add numbered lists.
- ’dl’ - Add description lists.
- ’bq’ - Add blockquotes.
- ’code’ - Add code samples.
- ’headers’ - Add headers.
- trailing_newlines – (Default = False) If False, strip trailing new lines in generated text. If True, leave trailing new lines in.
Returns: Result of querying loripsum.net API using the specified options