Skip to content

Commit b42ed03

Browse files
committed
Backup option for applying every docker start
1 parent 08c732e commit b42ed03

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mass_string_replacer.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import re
66
import sys
7-
7+
from shutil import copyfile
88

99
class RandomString:
1010
source : str = ""
@@ -92,8 +92,15 @@ def processYAML(config : Config):
9292
action: Action
9393
for action in config.actions:
9494
if os.path.isfile(action.path):
95+
readPath = action.path
96+
if usebackups:
97+
readPath = action.path + ".rep.backup";
98+
if not os.path.exists(readPath):
99+
copyfile(action.path, readPath)
100+
101+
95102
p("Procesing file '" + action.path + "'")
96-
with open(action.path, 'r') as file:
103+
with open(readPath, 'r') as file:
97104
fileText: str = file.read()
98105

99106
# Simple text replace:
@@ -170,6 +177,7 @@ def d(s : str, prefix : str = "-"): # log detail
170177
config = Config.fromDict(loadYAML(sys.argv[1]));
171178
dryRun:bool = not "--wet" in sys.argv
172179
silent:bool = "--silent" in sys.argv
180+
usebackups:bool = "--backup" in sys.argv and not dryRun
173181

174182
processYAML(config);
175183

0 commit comments

Comments
 (0)