Added comments

This commit is contained in:
Jerzy Drozdz 2018-05-22 21:28:03 +02:00 committed by rallytime
parent f3517a1852
commit b9ddd53b04
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -1922,6 +1922,8 @@ def line(path, content=None, match=None, mode=None, location=None,
with salt.utils.files.fopen(path, mode='r') as fp_:
body = salt.utils.data.decode_list(fp_.readlines())
body_before = hashlib.sha256(salt.utils.stringutils.to_bytes(''.join(body))).hexdigest()
# Add empty line at the end if last line ends with eol.
# Allows simpler code
if body and _get_eol(body[-1]):
body.append('')
@ -2017,6 +2019,7 @@ def line(path, content=None, match=None, mode=None, location=None,
if not _get_eol(line) and idx+1 < len(body):
prev = idx and idx-1 or 1
body[idx] = _set_line_eol(body[prev], line)
# We do not need empty line at the end anymore
if '' == body[-1]:
body.pop()