Name | paragraphs JSON |
Version |
1.0.1
JSON |
| download |
home_page | None |
Summary | Incorporate long strings painlessly, beautifully into Python code. |
upload_time | 2024-08-11 18:15:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# paragraphs
Incorporate long strings painlessly, beautifully into Python code.
## Examples
**Easily edited, `gq`-able, `fill-paragraph`-able, comprehensive error messages.**
```python
from paragraphs import par
class SuddenDeathError(Exception):
def __init__(self, cause: str) -> None:
self.cause = cause
def __str__(self) -> str:
return par(
f"""
Y - e - e - e - es, Lord love you! Why should she die of
{self.cause}? She come through diphtheria right enough the year
before. I saw her with my own eyes. Fairly blue with it, she was.
They all thought she was dead; but my father, he kept ladling gin
down her throat till she came to so sudden that she bit the bowl
off the spoon.
What call would a woman with that strength in her have to die of
{self.cause}? What become of her new straw hat that should have
come to me? Somebody pinched it; and what I say is, them as pinched
it done her in."""
)
raise SuddenDeathError("influenza")
```
**Nicely-formatted long string data. Spoilers for some old novels here,
but these *are* the original titles.**
```python
author2titles = {
"Samuel Penhallow": [
par(
"""
The history of the wars of New-England with the Eastern Indians;
or, a narrative of their continued perfidy and cruelty, from the
10th of August, 1703, to the peace renewed 13th of July, 1713. And
from the 25th of July, 1722, to their submission 15th December,
1725, which was ratified August 5th, 1726"""
)
],
"Daniel Defoe": [
par(
"""
The Life and Strange Surprizing Adventures of Robinson Crusoe, Of
York, Mariner: Who lived Eight and Twenty Years, all alone in an
un-inhabited Island on the Coast of America, near the Mouth of the
Great River of Oroonoque; Having been cast on Shore by Shipwreck,
wherein all the Men perished but himself. With An Account how he
was at last as strangely deliver'd by Pyrates"""
),
par(
"""The Fortunes and Misfortunes of the Famous Moll Flanders Who was
born in Newgate, and during a life of continu’d Variety for
Threescore Years, besides her Childhood, was Twelve Years a Whore,
five times a Wife (whereof once to her brother) Twelve Years a
Thief, Eight Years a Transported Felon in Virginia, at last grew
Rich, liv’d Honest and died a Penitent"""
),
],
}
```
## Installation
```bash
pip install paragraphs
```
## Use
```python
from paragraphs import par
PARAGRAPH = par(
"""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."""
)
# the above is equivalent to
PARAGRAPH = (
"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."
)
```
## Features
Joins lines. Removes indentation and leading whitespace.
```python
>>> par(
"""Lorem ipsum dolor
sit amet,"""
)
Lorem ipsum dolor sit amet,
```
Ignores one leading newline.
```python
>>> par(
"""
Lorem ipsum dolor
sit amet,"""
)
Lorem ipsum dolor sit amet,
```
Separates paragraphs with double newline (`"\n\n"`).
```python
>>> par (
"""
Lorem ipsum dolor
sit amet,
consectetur
adipiscing
elit"""
)
Lorem ipsum dolor sit amet,
<blankline>
consectetur adipiscing elit
```
Retains one trailing newline (if present).
```python
>>> par(
"""retains one trailing newline
"""
)
retains one trailing newline
<blankline>
>>> par("""no trailing newline""")
no trailing newline
```
## Notes
converts all whitespace to " "
```python
>>> par("""converts\tall\twhitespace\tto\<space>""")
converts all whitespace to <space>
```
compresses consecutive whitespace to " "
```python
>>> par("""compresses consecutive whitespace""")
compresses consecutive whitespace
```
Raw data
{
"_id": null,
"home_page": null,
"name": "paragraphs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Shay Hill <shay_public@hotmail.com>",
"download_url": "https://files.pythonhosted.org/packages/24/71/2462530f2e70991c1d19c03423a0bc1cdde8e49a415762edaebe7c19f9a3/paragraphs-1.0.1.tar.gz",
"platform": null,
"description": "# paragraphs\r\n\r\nIncorporate long strings painlessly, beautifully into Python code.\r\n\r\n## Examples\r\n\r\n**Easily edited, `gq`-able, `fill-paragraph`-able, comprehensive error messages.**\r\n```python\r\nfrom paragraphs import par\r\n\r\nclass SuddenDeathError(Exception):\r\n def __init__(self, cause: str) -> None:\r\n self.cause = cause\r\n\r\n def __str__(self) -> str:\r\n return par(\r\n f\"\"\"\r\n Y - e - e - e - es, Lord love you! Why should she die of\r\n {self.cause}? She come through diphtheria right enough the year\r\n before. I saw her with my own eyes. Fairly blue with it, she was.\r\n They all thought she was dead; but my father, he kept ladling gin\r\n down her throat till she came to so sudden that she bit the bowl\r\n off the spoon.\r\n\r\n What call would a woman with that strength in her have to die of\r\n {self.cause}? What become of her new straw hat that should have\r\n come to me? Somebody pinched it; and what I say is, them as pinched\r\n it done her in.\"\"\"\r\n )\r\n\r\nraise SuddenDeathError(\"influenza\")\r\n```\r\n\r\n**Nicely-formatted long string data. Spoilers for some old novels here,\r\nbut these *are* the original titles.**\r\n\r\n```python\r\nauthor2titles = {\r\n \"Samuel Penhallow\": [\r\n par(\r\n \"\"\"\r\n The history of the wars of New-England with the Eastern Indians;\r\n or, a narrative of their continued perfidy and cruelty, from the\r\n 10th of August, 1703, to the peace renewed 13th of July, 1713. And\r\n from the 25th of July, 1722, to their submission 15th December,\r\n 1725, which was ratified August 5th, 1726\"\"\"\r\n )\r\n ],\r\n \"Daniel Defoe\": [\r\n par(\r\n \"\"\"\r\n The Life and Strange Surprizing Adventures of Robinson Crusoe, Of\r\n York, Mariner: Who lived Eight and Twenty Years, all alone in an\r\n un-inhabited Island on the Coast of America, near the Mouth of the\r\n Great River of Oroonoque; Having been cast on Shore by Shipwreck,\r\n wherein all the Men perished but himself. With An Account how he\r\n was at last as strangely deliver'd by Pyrates\"\"\"\r\n ),\r\n par(\r\n \"\"\"The Fortunes and Misfortunes of the Famous Moll Flanders Who was\r\n born in Newgate, and during a life of continu\u2019d Variety for\r\n Threescore Years, besides her Childhood, was Twelve Years a Whore,\r\n five times a Wife (whereof once to her brother) Twelve Years a\r\n Thief, Eight Years a Transported Felon in Virginia, at last grew\r\n Rich, liv\u2019d Honest and died a Penitent\"\"\"\r\n ),\r\n ],\r\n}\r\n```\r\n\r\n## Installation\r\n```bash\r\npip install paragraphs\r\n```\r\n\r\n## Use\r\n\r\n```python\r\nfrom paragraphs import par\r\n\r\nPARAGRAPH = par(\r\n \"\"\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\r\n tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\r\n veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\r\n commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\r\n velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat\r\n cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id\r\n est laborum.\"\"\"\r\n)\r\n\r\n# the above is equivalent to\r\n\r\nPARAGRAPH = (\r\n \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\"\r\n + \" tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\"\r\n + \" veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\"\r\n + \" commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\"\r\n + \" velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\"\r\n + \" occaecat cupidatat non proident, sunt in culpa qui officia deserunt\"\r\n + \" mollit anim id est laborum.\"\r\n)\r\n\r\n```\r\n\r\n## Features\r\n\r\nJoins lines. Removes indentation and leading whitespace.\r\n\r\n```python\r\n>>> par(\r\n \"\"\"Lorem ipsum dolor\r\n sit amet,\"\"\"\r\n)\r\n\r\nLorem ipsum dolor sit amet,\r\n```\r\n\r\nIgnores one leading newline.\r\n\r\n```python\r\n>>> par(\r\n \"\"\"\r\n Lorem ipsum dolor\r\n sit amet,\"\"\"\r\n)\r\n\r\nLorem ipsum dolor sit amet,\r\n```\r\n\r\nSeparates paragraphs with double newline (`\"\\n\\n\"`).\r\n\r\n```python\r\n>>> par (\r\n \"\"\"\r\n Lorem ipsum dolor\r\n sit amet,\r\n\r\n consectetur\r\n adipiscing\r\n elit\"\"\"\r\n)\r\n\r\nLorem ipsum dolor sit amet,\r\n<blankline>\r\nconsectetur adipiscing elit\r\n```\r\n\r\nRetains one trailing newline (if present).\r\n\r\n```python\r\n>>> par(\r\n \"\"\"retains one trailing newline\r\n \"\"\"\r\n)\r\n\r\nretains one trailing newline\r\n<blankline>\r\n\r\n>>> par(\"\"\"no trailing newline\"\"\")\r\n\r\nno trailing newline\r\n```\r\n\r\n## Notes\r\n\r\nconverts all whitespace to \" \"\r\n\r\n```python\r\n>>> par(\"\"\"converts\\tall\\twhitespace\\tto\\<space>\"\"\")\r\n\r\nconverts all whitespace to <space>\r\n```\r\n\r\ncompresses consecutive whitespace to \" \"\r\n\r\n```python\r\n>>> par(\"\"\"compresses consecutive whitespace\"\"\")\r\n\r\ncompresses consecutive whitespace\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Incorporate long strings painlessly, beautifully into Python code.",
"version": "1.0.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1879806f22675c50f9cc827376756186c8601ef52a9cf08d2c7b80964e1daba2",
"md5": "d904ce6e6fd7ee6b562050cffe723f0b",
"sha256": "9a189d8dfc6241b5caa9b3ae730ee6ccce53e483d3b45183d13f657f7d0d1b35"
},
"downloads": -1,
"filename": "paragraphs-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d904ce6e6fd7ee6b562050cffe723f0b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5139,
"upload_time": "2024-08-11T18:15:56",
"upload_time_iso_8601": "2024-08-11T18:15:56.188420Z",
"url": "https://files.pythonhosted.org/packages/18/79/806f22675c50f9cc827376756186c8601ef52a9cf08d2c7b80964e1daba2/paragraphs-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "24712462530f2e70991c1d19c03423a0bc1cdde8e49a415762edaebe7c19f9a3",
"md5": "83d2139ded80c1636b10cc8c05baa165",
"sha256": "ad393f2e99432740f36c115280aa454c53c8048e6a2cda0b81df4effc8043a60"
},
"downloads": -1,
"filename": "paragraphs-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "83d2139ded80c1636b10cc8c05baa165",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 7045,
"upload_time": "2024-08-11T18:15:57",
"upload_time_iso_8601": "2024-08-11T18:15:57.551881Z",
"url": "https://files.pythonhosted.org/packages/24/71/2462530f2e70991c1d19c03423a0bc1cdde8e49a415762edaebe7c19f9a3/paragraphs-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-11 18:15:57",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "paragraphs"
}