show replace content just if to replace content exist

This commit is contained in:
Kevin Veen-Birkenbach 2023-08-22 22:39:36 +02:00
parent 71f5db9f74
commit df49d43c50

View File

@ -5,6 +5,7 @@ def replace_content(path, old_string, new_string, preview, verbose):
with open(path, 'r', encoding='utf-8') as f: with open(path, 'r', encoding='utf-8') as f:
content = f.read() content = f.read()
if old_string in content: # Prüfen, ob der alte String im Inhalt vorkommt
new_content = content.replace(old_string, new_string) new_content = content.replace(old_string, new_string)
if verbose: if verbose: