Feature: Use indent

This commit is contained in:
Bo Maryniuk 2015-03-26 17:33:57 +01:00
parent 8fcb94473f
commit 7338c2e40a

View File

@ -1302,10 +1302,9 @@ def line(path, content, match=None, mode=None, location=None,
body = os.linesep.join([line for line in body.split(os.linesep) if line.find(match) < 0]) body = os.linesep.join([line for line in body.split(os.linesep) if line.find(match) < 0])
elif mode == 'replace': elif mode == 'replace':
if body.find(match) > -1: body = os.linesep.join([(_get_line_indent(line, content, indent)
body = body.replace(match, content) if (line.find(match) > -1 and not line == content) else line)
elif re.search(match, body): for line in body.split(os.linesep)])
body = re.sub(match, content, body)
elif mode == 'insert': elif mode == 'insert':
if not location and not before and not after: if not location and not before and not after:
raise CommandExecutionError('On insert must be defined either "location" or "before/after" conditions.') raise CommandExecutionError('On insert must be defined either "location" or "before/after" conditions.')