{"id":21082160,"url":"https://github.com/olsonpm/py_tedent","last_synced_at":"2025-03-14T04:42:59.871Z","repository":{"id":57473791,"uuid":"166742185","full_name":"olsonpm/py_tedent","owner":"olsonpm","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-19T20:05:27.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-02-21T06:46:43.306Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olsonpm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-21T03:24:30.000Z","updated_at":"2019-05-19T20:05:28.000Z","dependencies_parsed_at":"2022-09-26T17:40:59.402Z","dependency_job_id":null,"html_url":"https://github.com/olsonpm/py_tedent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_tedent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_tedent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_tedent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_tedent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olsonpm","download_url":"https://codeload.github.com/olsonpm/py_tedent/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526853,"owners_count":20305112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T20:13:01.980Z","updated_at":"2025-03-14T04:42:59.846Z","avatar_url":"https://github.com/olsonpm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tedent\n\nKeep your multi-line templated strings lookin' good :sunglasses:\n\n*This is a python version of [tedent](https://github.com/olsonpm/tedent)*\n\n\u003cbr\u003e\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n- [What is it?](#what-is-it)\n- [What does the name stand for?](#what-does-the-name-stand-for)\n- [Why create it?](#why-create-it)\n- [Simple Usage](#simple-usage)\n- [Questions about how the indentation works?](#questions-about-how-the-indentation-works)\n- [Important Usage Notes](#important-usage-notes)\n  - [input requirements](#edge-cases-and-input-requirements)\n- [Test](#test)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\u003cbr\u003e\n\n### What is it?\n\n- A function similar to [dedent](https://docs.python.org/3.7/library/textwrap.html#textwrap.dedent)\n  just with different semantics\n\n\u003cbr\u003e\n\n### What does the name stand for?\n\n- `Te`mplate string\n- in`dent`ation\n\nnames are hard\n\n\u003cbr\u003e\n\n### Why create it?\n\n- dedent didn't handle the following case like I wanted\n\n```py\nformattedBoroughs = f\"\"\"\\\n[\n    'Brooklyn',\n    'Manhattan',\n]\n\"\"\"\n\nprint(\n    dedent(\n        f\"\"\"\\\n        New York boroughs\n        ${formattedBoroughs}\n        \"\"\"\n    )\n)\n\n#\n# expected:\n# New York boroughs\n# [\n#     'Brooklyn',\n#     'Manhattan',\n# ]\n#\n# actual:\n#         New York boroughs\n#         [\n#     'Brooklyn',\n#     'Manhattan',\n# ]\n#\n```\n\n\u003cbr\u003e\n\n### Simple Usage\n\n```py\nimport tedent from 'tedent'\n\n#\n# *note the lack of the backslash\n#\nprint(\n    tedent(\n        \"\"\"\n        This will be indented\n          as you expect\n        \"\"\"\n    )\n)\n\n# writes:\n# This will be indented\n#   as you expect\n```\n\n\u003cbr\u003e\n\n### Questions about how the indentation works?\n\nBecause the indentation logic is both young and convoluted, please refer to\n[the code](tedent/index.py) and [tests](tests/simple.py) for details. The\nlibrary is not that big and if you have any questions please create a\ngithub issue.\n\n\u003cbr\u003e\n\n### Important Usage Notes\n\n- First of all, this library doesn't handle tabs. I will accept a PR\n  with support\n\n- Secondly, if you always use `tedent` like the following\n\n  ```py\n  tedent(\n      \"\"\"\n      some text\n      \"\"\"\n  )\n  ```\n\n  then you shouldn't run into any issues. However we all know input can be\n  tricky so `tedent` has a few input requirements in order to format your\n  string properly.\n\n#### input requirements\n\n- if the argument isn't a string then an error will be thrown\n- if you pass a string with three or more newlines, then\n  - the first and last lines must contain only whitespace\n  - the second line must contain a non-whitespace character\n  - _an error will be thrown if the above two conditions are not met_\n- if you pass a string with fewer than 3 newlines\n  - if they only contain whitespace then an empty string is returned\n  - otherwise an error is thrown\n- finally, all trailing whitespace from the result is stripped\n\nIf you have questions please raise a github issue.\n\n\u003cbr\u003e\n\n### Test\n\n```py\n#\n# you must have poetry installed\n#\n$ poetry shell\n$ poetry install\n$ python runTests.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fpy_tedent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folsonpm%2Fpy_tedent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fpy_tedent/lists"}