Skip to content

Commit

Permalink
Update text_utils.py (#17)
Browse files Browse the repository at this point in the history
* Update text_utils.py

* update docs
  • Loading branch information
MP91 authored Jun 20, 2024
1 parent 67803f9 commit e9b45d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/velocitas_lib.text_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Replace all occurrences of text in a file with a replacement.

---

<a href="../velocitas_lib/text_utils.py#L65"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../velocitas_lib/text_utils.py#L68"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `replace_item_in_list`

Expand All @@ -109,7 +109,7 @@ Replace the whole line which matches the given text with a replacement.

---

<a href="../velocitas_lib/text_utils.py#L93"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../velocitas_lib/text_utils.py#L96"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `replace_text_area`

Expand All @@ -136,7 +136,7 @@ Replace all occurrences of all text areas matching the parameters with a replace

---

<a href="../velocitas_lib/text_utils.py#L126"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../velocitas_lib/text_utils.py#L129"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `capture_area_in_file`

Expand Down
3 changes: 3 additions & 0 deletions velocitas_lib/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def replace_text_in_file(file_path: str, text: str, replacement: str) -> None:
file_text = file.readlines()
replaced_text_list = replace_item_in_list(file_text, text, replacement)
replaced_text = "".join(replaced_text_list)
# replace old content
file.seek(0)
file.write(replaced_text)
file.truncate()


def replace_item_in_list(
Expand Down

0 comments on commit e9b45d9

Please sign in to comment.