Spaces in raw format was fixed #24

master
Иванов Денис 3 years ago
parent 80da6602f0
commit 9140335ad5

@ -32,7 +32,7 @@ class RawFormat(Format):
@property
def document_text(self):
return '{}{}'.format(self.header, self._document_text)
return '{}{}\n'.format(self.header, self._document_text)
def join_template(self, template):
if self._before:
@ -44,9 +44,9 @@ class RawFormat(Format):
else:
self._document_text = '{0}{1}{2}'.format(
self._document_text,
"" if template._document_text.
"" if self._document_text.
endswith("\n") else "\n",
template._document_text)
def __bool__(self):
return bool(self.document_text)
return bool(self.document_text.strip())

@ -18,7 +18,8 @@ parameter-5 = e;'''
parameter-2 = b;
parameter-3 = c;
parameter-4 = d;
parameter-5 = e;'''
parameter-5 = e;
'''
raw_document_1 = RawFormat(original, 'path/to/template')
raw_document_2 = RawFormat(template, 'path/to/template')
@ -38,7 +39,8 @@ parameter-5 = e;'''
parameter-5 = e;
parameter-1 = a;
parameter-2 = b;
parameter-3 = c;'''
parameter-3 = c;
'''
raw_document_1 = RawFormat(document_1, 'path/to/template',
join_before=True)
@ -65,7 +67,8 @@ parameter-1 = a;
parameter-2 = b;
parameter-3 = c;
parameter-4 = d;
parameter-5 = e;'''
parameter-5 = e;
'''
raw_document_1 = RawFormat(document_1, 'path/to/template',
add_header=True, parameters=parameters)
@ -93,7 +96,8 @@ parameter-4 = d;
parameter-5 = e;
parameter-1 = a;
parameter-2 = b;
parameter-3 = c;'''
parameter-3 = c;
'''
raw_document_1 = RawFormat(document_1, 'path/to/template',
join_before=True, add_header=True,
@ -125,7 +129,8 @@ parameter-2 = b;
parameter-3 = c;
parameter-4 = d;
parameter-5 = e;
parameter-6 = f;'''
parameter-6 = f;
'''
original_1 = RawFormat(original_text, 'path/to/template_1',
add_header=True,
@ -160,7 +165,8 @@ parameter-2 = b;
parameter-3 = c;
parameter-4 = d;
parameter-5 = e;
parameter-6 = f;'''
parameter-6 = f;
'''
original_1 = RawFormat(original_text, 'path/to/template_1',
add_header=True,

@ -1427,7 +1427,7 @@ class TestDirectoryProcessor:
'/etc/dir_61/._cfg0000_file_0'),
'r') as new_file:
new_text = new_file.read()
assert new_text == '\nnew content'
assert new_text == '\nnew content\n'
def test_current_template_variable(self):
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
@ -1439,7 +1439,7 @@ class TestDirectoryProcessor:
'# Processed template files:\n' +
f'# {template_path}\n' +
'#' + '-' * 79 +
f'\n\ntemplate = {template_path}')
f'\n\ntemplate = {template_path}\n')
directory_processor = DirectoryProcessor(
'install',
datavars_module=datavars,

Loading…
Cancel
Save