Name | formatted-join JSON |
Version |
1.1.2
JSON |
| download |
home_page | None |
Summary | Utility for joining string lists with flexible separator formatting. |
upload_time | 2024-12-22 03:55:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 Sash Sinha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
comma
join
separators
utilities
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<h1 align="center">Formatted Join ✅</h1>
<h3 align="center">Effortlessly join string sequences with flexible separator formatting for clear, polished output</h3>
<br/>
<p align="center">
<a href="https://raw.githubusercontent.com/sashsinha/formatted-join/main/LICENCE"><img alt="License: MIT" src="https://raw.githubusercontent.com/sashsinha/formatted-join/main/license.svg"></a>
<a href="https://pypi.org/project/formatted-join/"><img alt="PyPI" src="https://img.shields.io/pypi/v/formatted-join"></a>
<a href="https://pypi.org/project/formatted-join/"><img alt="PyPI Status" src="https://img.shields.io/pypi/status/formatted-join"></a>
<a href="https://pepy.tech/project/formatted-join"><img alt="Downloads" src="https://pepy.tech/badge/formatted-join"></a>
</p>
### Installation
#### PyPI
```
pip install formatted-join
```
#### [`uv`](https://github.com/astral-sh/uv)
```
uv add formatted-join
```
### Usage Examples
#### `formatted_join(items: Sequence[str], separator=', ', final_separator=' and ', use_penultimate_separator=True) -> str`
Joins items with flexible separator configuraton.
```py
>>> from formatted_join import formatted_join
>>> formatted_join(['Hello', 'World'])
'Hello and World'
>>> formatted_join(('A', 'B', 'C'))
'A, B, and C'
>>> formatted_join(['X', 'Y', 'Z', 'W'], separator=' | ', final_separator=' & ')
'X | Y | Z & W'
>>> formatted_join(['Solo'])
'Solo'
>>> formatted_join(['', ''])
' and '
>>> formatted_join(
... items=['Alpha', 'Bravo', 'Charlie', 'Delta'],
... separator=' | ',
... final_separator=' & ',
... use_penultimate_separator=False
... )
'Alpha | Bravo | Charlie & Delta'
>>> formatted_join(['One', 'Two'], final_separator=' ~ ')
'One ~ Two'
```
---
#### `formatted_join_conjunction(items: Sequence[str], language: str = 'en') -> str`
Joins items using a comma and localized* “and” before the last item.
```py
>>> from formatted_join import formatted_join_conjunction
>>> formatted_join_conjunction(['Spring', 'Summer'])
'Spring and Summer'
>>> formatted_join_conjunction(['One', 'Two', 'Three'])
'One, Two, and Three'
>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='en')
'Motorcycle, Bus, and Car'
>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='de')
'Motorcycle, Bus und Car'
```
---
#### `formatted_join_disjunction(items: Sequence[str], language: str = 'en') -> str`
Joins items using a comma and localized* “or” before the last item.
```py
>>> from formatted_join import formatted_join_disjunction
>>> formatted_join_disjunction(['Monday', 'Tuesday'])
'Monday or Tuesday'
>>> formatted_join_disjunction(['X', 'Y', 'Z'])
'X, Y, or Z'
>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='en')
'Motorcycle, Bus, or Car'
>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='de')
'Motorcycle, Bus oder Car'
```
---
#### `formatted_join_unit(items: Sequence[str]) -> str`
Joins items with commas only (no distinct final separator).
```py
>>> from formatted_join import formatted_join_unit
>>> formatted_join_unit(['A'])
'A'
>>> formatted_join_unit(['A', 'B', 'C', 'D'])
'A, B, C, D'
```
---
#### `formatted_join_narrow(items: Sequence[str]) -> str`
Joins items with a single space separating each.
```py
>>> from formatted_join import formatted_join_narrow
>>> formatted_join_narrow(['Only'])
'Only'
>>> formatted_join_narrow(['A', 'B', 'C'])
'A B C'
>>> formatted_join_narrow(['Line1', '-', 'Line2'])
'Line1 - Line2'
```
----
#### * Supported languages for `formatted_join_[conjunction|disjunction]`:
| language | and | or | separator | has penultimate separator |
| -------- | --- | ---- | --------- | ------------------------- |
| en | and | or | `', '` | yes |
| de | und | oder | `', '` | no |
### Development
- Install Dependencies:
- `uv sync && uv pip install -r pyproject.toml --extra dev`
- Run formater:
- `uv run ruff check --select I --fix && uv run ruff format`
- Run type checking:
- `uv run mypy .`
- Run unit tests:
- `uv run formatted_join_test.py`
Raw data
{
"_id": null,
"home_page": null,
"name": "formatted-join",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Sash Sinha <sashsinha1@gmail.com>",
"keywords": "comma, join, separators, utilities",
"author": null,
"author_email": "Sash Sinha <sashsinha1@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e8/64/c55d2c2c0a606370fcd6e6059fa9645f3dee2fbefe149be4bfda72babee1/formatted_join-1.1.2.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">Formatted Join \u2705</h1>\n\n<h3 align=\"center\">Effortlessly join string sequences with flexible separator formatting for clear, polished output</h3>\n\n<br/>\n\n<p align=\"center\">\n<a href=\"https://raw.githubusercontent.com/sashsinha/formatted-join/main/LICENCE\"><img alt=\"License: MIT\" src=\"https://raw.githubusercontent.com/sashsinha/formatted-join/main/license.svg\"></a>\n<a href=\"https://pypi.org/project/formatted-join/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/formatted-join\"></a>\n<a href=\"https://pypi.org/project/formatted-join/\"><img alt=\"PyPI Status\" src=\"https://img.shields.io/pypi/status/formatted-join\"></a>\n<a href=\"https://pepy.tech/project/formatted-join\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/formatted-join\"></a>\n</p>\n\n### Installation\n\n#### PyPI\n```\npip install formatted-join\n```\n\n#### [`uv`](https://github.com/astral-sh/uv)\n```\nuv add formatted-join\n```\n\n### Usage Examples\n\n#### `formatted_join(items: Sequence[str], separator=', ', final_separator=' and ', use_penultimate_separator=True) -> str`\nJoins items with flexible separator configuraton.\n```py\n>>> from formatted_join import formatted_join\n>>> formatted_join(['Hello', 'World'])\n'Hello and World'\n>>> formatted_join(('A', 'B', 'C'))\n'A, B, and C'\n>>> formatted_join(['X', 'Y', 'Z', 'W'], separator=' | ', final_separator=' & ')\n'X | Y | Z & W'\n>>> formatted_join(['Solo'])\n'Solo'\n>>> formatted_join(['', ''])\n' and '\n>>> formatted_join(\n... items=['Alpha', 'Bravo', 'Charlie', 'Delta'],\n... separator=' | ',\n... final_separator=' & ',\n... use_penultimate_separator=False\n... )\n'Alpha | Bravo | Charlie & Delta'\n>>> formatted_join(['One', 'Two'], final_separator=' ~ ')\n'One ~ Two'\n```\n\n---\n\n#### `formatted_join_conjunction(items: Sequence[str], language: str = 'en') -> str`\nJoins items using a comma and localized* \u201cand\u201d before the last item.\n```py\n>>> from formatted_join import formatted_join_conjunction\n>>> formatted_join_conjunction(['Spring', 'Summer'])\n'Spring and Summer'\n>>> formatted_join_conjunction(['One', 'Two', 'Three'])\n'One, Two, and Three'\n>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='en')\n'Motorcycle, Bus, and Car'\n>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='de')\n'Motorcycle, Bus und Car'\n```\n\n---\n\n#### `formatted_join_disjunction(items: Sequence[str], language: str = 'en') -> str`\nJoins items using a comma and localized* \u201cor\u201d before the last item.\n```py\n>>> from formatted_join import formatted_join_disjunction\n>>> formatted_join_disjunction(['Monday', 'Tuesday'])\n'Monday or Tuesday'\n>>> formatted_join_disjunction(['X', 'Y', 'Z'])\n'X, Y, or Z'\n>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='en')\n'Motorcycle, Bus, or Car'\n>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='de')\n'Motorcycle, Bus oder Car'\n```\n\n---\n\n#### `formatted_join_unit(items: Sequence[str]) -> str`\nJoins items with commas only (no distinct final separator).\n```py\n>>> from formatted_join import formatted_join_unit\n>>> formatted_join_unit(['A'])\n'A'\n>>> formatted_join_unit(['A', 'B', 'C', 'D'])\n'A, B, C, D'\n```\n\n---\n\n#### `formatted_join_narrow(items: Sequence[str]) -> str`\nJoins items with a single space separating each.\n```py\n>>> from formatted_join import formatted_join_narrow\n>>> formatted_join_narrow(['Only'])\n'Only'\n>>> formatted_join_narrow(['A', 'B', 'C'])\n'A B C'\n>>> formatted_join_narrow(['Line1', '-', 'Line2'])\n'Line1 - Line2'\n```\n\n---- \n\n#### * Supported languages for `formatted_join_[conjunction|disjunction]`:\n\n| language | and | or | separator | has penultimate separator |\n| -------- | --- | ---- | --------- | ------------------------- |\n| en | and | or | `', '` | yes |\n| de | und | oder | `', '` | no |\n\n### Development\n- Install Dependencies:\n - `uv sync && uv pip install -r pyproject.toml --extra dev`\n- Run formater:\n - `uv run ruff check --select I --fix && uv run ruff format`\n- Run type checking:\n - `uv run mypy .`\n- Run unit tests:\n - `uv run formatted_join_test.py`\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Sash Sinha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Utility for joining string lists with flexible separator formatting.",
"version": "1.1.2",
"project_urls": {
"Documentation": "https://github.com/sashsinha/formatted-join/blob/main/README.md",
"Homepage": "https://github.com/sashsinha/formatted-join",
"Repository": "https://github.com/sashsinha/formatted-join.git"
},
"split_keywords": [
"comma",
" join",
" separators",
" utilities"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "066e652475af754d4f93418df310ad19212097e614d61ba0bdc054817a3ee21d",
"md5": "891b914a58136e86c7a7ff27799400ad",
"sha256": "2ef38c3d71ca364be5db9024c9576f69fe69cb01975b21608e8f3f5b8b618a7b"
},
"downloads": -1,
"filename": "formatted_join-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "891b914a58136e86c7a7ff27799400ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 5254,
"upload_time": "2024-12-22T03:55:29",
"upload_time_iso_8601": "2024-12-22T03:55:29.672662Z",
"url": "https://files.pythonhosted.org/packages/06/6e/652475af754d4f93418df310ad19212097e614d61ba0bdc054817a3ee21d/formatted_join-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e864c55d2c2c0a606370fcd6e6059fa9645f3dee2fbefe149be4bfda72babee1",
"md5": "7b7bce7038bfab803dec349bd55cfbe5",
"sha256": "d191d4635976f474e94a8cb041c7d78f79edc5ad7146b56112795aee036c4c1e"
},
"downloads": -1,
"filename": "formatted_join-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "7b7bce7038bfab803dec349bd55cfbe5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 15286,
"upload_time": "2024-12-22T03:55:31",
"upload_time_iso_8601": "2024-12-22T03:55:31.926229Z",
"url": "https://files.pythonhosted.org/packages/e8/64/c55d2c2c0a606370fcd6e6059fa9645f3dee2fbefe149be4bfda72babee1/formatted_join-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 03:55:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sashsinha",
"github_project": "formatted-join",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "formatted-join"
}