+def remove_lines(s_regex, e_regex, f):
+ f = joinpath(release_dir, f)
+ if isinstance(s_regex, str):
+ s_regex = re.compile(s_regex)
+ if isinstance(e_regex, str):
+ e_regex = re.compile(e_regex)
+ inscript = file(f, 'r').readlines()
+ outscript = file(f, 'w')
+ skipping = False
+ for line in inscript:
+ if (not skipping and s_regex.match(line)) or \
+ (e_regex and skipping and not e_regex.match(line)):
+ if e_regex:
+ skipping = True
+ continue
+ skipping = False
+ outscript.write(line)
+ outscript.close()
+
+def replace_line(s_regex, f, rl):
+ f = joinpath(release_dir, f)
+ if isinstance(s_regex, str):
+ s_regex = re.compile(s_regex)
+ inscript = file(f, 'r').readlines()
+ outscript = file(f, 'w')
+ for line in inscript:
+ if s_regex.match(line):
+ outscript.write(rl)
+ continue
+ outscript.write(line)
+ outscript.close()
+
+