Now regex templates with parameter comment = '' do not add calculate comment. fixed #70

master
Иванов Денис 3 years ago
parent d45688ffd0
commit 24bd7b3e63

@ -370,6 +370,7 @@ class Format():
return header, document_text
def _make_header(self, template_paths: list):
print('making header...')
if not self.comment_symbol:
return ""
elif self.comment_symbol in ("xml", "XML"):

@ -29,6 +29,9 @@ class RegexFormat(Format):
self._multiline_flag = parameters.multiline
self._dotall_flag = parameters.dotall
if parameters.comment is not False:
self.comment_symbol = parameters.comment
print(f'comment symbol is set to: "{self.comment_symbol}"')
self._parsed_patch = None
if add_header and not ignore_comments:

@ -320,6 +320,64 @@ WorldWWWW
Testing
'''
original_object = RegexFormat(original_text, '/path/to/template',
add_header=True, already_changed=True,
parameters=parameters)
template_object = RegexFormat(template_text, '/path/to/template',
parameters=parameters)
original_object.join_template(template_object)
assert original_object.document_text == join_result
def test_format_with_empty_comment_parameter(self):
parameters = ParametersContainer({'multiline': True,
'dotall': True,
'comment': ''})
original_text = '''
Hello
'''
template_text = r'''
<reg>Hello</reg>
<text></text>
'''
join_result = '''
'''
original_object = RegexFormat(original_text, '/path/to/template',
add_header=True, already_changed=True,
parameters=parameters)
template_object = RegexFormat(template_text, '/path/to/template',
parameters=parameters)
original_object.join_template(template_object)
assert original_object.document_text == join_result
def test_format_with_empty_comment_parameter_and_with_header_in_original_document(self):
parameters = ParametersContainer({'multiline': True,
'dotall': True,
'comment': ''})
original_text = '''#-------------------------------------------------------------------------------
# Modified by Calculate Utilities 4.0
# Processed template files:
# /path/to/ancient/template
#-------------------------------------------------------------------------------
Hello
'''
template_text = r'''
<reg>Hello</reg>
<text></text>
'''
join_result = '''#-------------------------------------------------------------------------------
# Modified by Calculate Utilities 4.0
# Processed template files:
# /path/to/ancient/template
#-------------------------------------------------------------------------------
'''
original_object = RegexFormat(original_text, '/path/to/template',

Loading…
Cancel
Save