Commit 3ac73108 by Peter Gehres Committed by James Cammarata

Fix for #6353 adding a newline between assembled files

parent 729e20ae
...@@ -102,21 +102,30 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None): ...@@ -102,21 +102,30 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None):
tmpfd, temp_path = tempfile.mkstemp() tmpfd, temp_path = tempfile.mkstemp()
tmp = os.fdopen(tmpfd,'w') tmp = os.fdopen(tmpfd,'w')
delimit_me = False delimit_me = False
for f in sorted(os.listdir(src_path)): for f in sorted(os.listdir(src_path)):
if compiled_regexp and not compiled_regexp.search(f): if compiled_regexp and not compiled_regexp.search(f):
continue continue
fragment = "%s/%s" % (src_path, f) fragment = "%s/%s" % (src_path, f)
if delimit_me and delimiter:
# un-escape anything like newlines # delimiters should only appear between fragments
delimiter = delimiter.decode('unicode-escape') if delimit_me:
tmp.write(delimiter) # always put a newline between fragments
# always make sure there's a newline after the tmp.write('\n')
# delimiter, so lines don't run together
if delimiter[-1] != '\n': if delimiter:
tmp.write('\n') # 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
if delimiter[-1] != '\n':
tmp.write('\n')
if os.path.isfile(fragment): if os.path.isfile(fragment):
tmp.write(file(fragment).read()) tmp.write(file(fragment).read())
delimit_me = True delimit_me = True
tmp.close() tmp.close()
return temp_path return temp_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment