-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TillerBurr/test_docs
- Loading branch information
Showing
5 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import textwrap | ||
|
||
|
||
def dedent(text: str) -> str: | ||
"""Dedent an indented string by the miniumum indentation level. | ||
Args: | ||
text: String to dedent | ||
Returns: | ||
dedented string | ||
""" | ||
return textwrap.dedent(text).strip("\n") | ||
|
||
|
||
def dedent_and_replace( | ||
to_dedent: str, to_replace: str, new: str, dedent_new: bool = True | ||
) -> str: | ||
"""Dedent and replace a string. | ||
Args: | ||
to_dedent: String to dedent | ||
to_replace: String to replace | ||
new: String to replace with | ||
dedent_new: Bool that is true if `new` should also be dedented. | ||
Returns: | ||
""" | ||
if dedent_new: | ||
new = dedent(new) | ||
return dedent(to_dedent).replace(to_replace, new) |