1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Un-escape newlines in delimiters for assemble module

This commit is contained in:
James Cammarata 2014-03-06 09:44:56 -06:00 committed by James Cammarata
parent 8e7a384fcc
commit 27d52fd9cc
2 changed files with 8 additions and 0 deletions

View file

@ -39,7 +39,13 @@ class ActionModule(object):
for f in sorted(os.listdir(src_path)):
fragment = "%s/%s" % (src_path, f)
if delimit_me and delimiter:
# en-escape things like new-lines
delimiter = delimiter.decode('unicode-escape')
tmp.write(delimiter)
# always make sure there's a newline after the
# delimiter, so lines don't run together
if delimiter[-1] != '\n':
tmp.write('\n')
if os.path.isfile(fragment):
tmp.write(file(fragment).read())
delimit_me = True

View file

@ -107,6 +107,8 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None):
continue
fragment = "%s/%s" % (src_path, f)
if delimit_me and delimiter:
# un-escape anything like newlines
delimiter = delimiter.decode('unicode-escape')
tmp.write(delimiter)
# always make sure there's a newline after the
# delimiter, so lines don't run together