XML comment format was changed. fixed #47

master
Иванов Денис 3 years ago
parent 2009c654ab
commit 7400444675

@ -363,9 +363,9 @@ class Format:
текста исходного файла.'''
header_pattern = self._get_header_pattern()
template_paths = []
if already_changed and self.comment_symbol:
header_regex = re.compile(header_pattern)
parsing_result = header_regex.search(input_text)
header_regex = re.compile(header_pattern)
parsing_result = header_regex.search(input_text)
if already_changed and self.comment_symbol and parsing_result:
for template in parsing_result.\
groupdict()['template_paths'].strip().split('\n'):
if template.startswith(self.comment_symbol):
@ -381,11 +381,11 @@ class Format:
return ""
elif self.comment_symbol in ("xml", "XML"):
return ("<?xml version='1.0' encoding='UTF-8'?>\n" +
'<!--' + '-' * 76 + '\n' +
'<!--\n' +
'Modified by Calculate Utilities {}\n' +
'Processed template files:\n' +
'\n'.join(template_paths) + '\n' +
'-' * 77 + '-->\n').format(self.CALCULATE_VERSION)
'-->\n').format(self.CALCULATE_VERSION)
else:
return ('{0}' + '-' * 79 + '\n' +
'{0} Modified by Calculate Utilities {1}\n' +
@ -396,11 +396,11 @@ class Format:
def _get_header_pattern(self) -> str:
if self.comment_symbol in {"xml", "XML"}:
return (r'<!--' + r'-' * 76 + r'\n' +
return (r'<!--\n' +
r'\s*Modified by Calculate Utilities [\d\w\.]*\n' +
r'\s*Processed template files:\n' +
r'\s*(?P<template_paths>(\s*[/\w\d\-_\.]*\n)+)' +
r'-' * 77 + r'-->\n?')
r'-->\n?')
else:
return (r'^{0}' + r'-' * 79 + r'\n' +
r'{0} Modified by Calculate Utilities [\d\w\.]*\n' +

@ -87,11 +87,11 @@ parameter-3 = c;'''
parameter-5 = e;'''
output = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
path/to/template
------------------------------------------------------------------------------->
-->
parameter-4 = d;
parameter-5 = e;
parameter-1 = a;

@ -141,11 +141,11 @@ class TestParsingMethods:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/template
------------------------------------------------------------------------------->
-->
<gconf>
<dir name="gnome">
<dir name="ymsgr">
@ -171,11 +171,11 @@ Processed template files:
def test_if_input_documents_are_an_original_document_with_calculate_header_and_a_template_the_add_header_flag_is_set_and_the_already_changed_flag_is_not_set__the_format_object_removes_calculate_header_from_original_document__joins_an_original_document_and_a_template_and_adds_the_calculate_header(self):
original_text = '''<?xml version="1.0" encoding="UTF-8"?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
------------------------------------------------------------------------------->
-->
<gconf>
<dir name="gnome">
<dir name="ymsgr">
@ -208,11 +208,11 @@ Processed template files:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/template
------------------------------------------------------------------------------->
-->
<gconf>
<dir name="gnome">
<dir name="ymsgr">
@ -238,11 +238,11 @@ Processed template files:
def test_if_input_documents_are_an_original_document_with_calculate_header_and_a_template_the_add_header_flag_is_set_and_the_already_changed_flag_is_set__the_format_object_joins_an_original_document_and_a_template_and_adds_the_calculate_header_with_a_template_paths_from_the_old_header_and_paths_to_a_current_template(self):
original_text = '''<?xml version="1.0" encoding="UTF-8"?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
------------------------------------------------------------------------------->
-->
<gconf>
<dir name="gnome">
<dir name="ymsgr">
@ -275,12 +275,12 @@ Processed template files:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
/path/to/template
------------------------------------------------------------------------------->
-->
<gconf>
<dir name="gnome">
<dir name="ymsgr">

@ -75,11 +75,11 @@ class TestParsingMethods:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/template
------------------------------------------------------------------------------->
-->
<channel name="xsettings" version="1.0">
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>
@ -95,11 +95,11 @@ Processed template files:
def test_if_input_documents_are_an_original_document_with_calculate_header_and_a_template_the_add_header_flag_is_set_and_the_already_changed_flag_is_not_set__the_format_object_removes_calculate_header_from_original_document__joins_an_original_document_and_a_template_and_adds_the_calculate_header(self):
original_text = '''<?xml version="1.0" encoding="UTF-8"?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
------------------------------------------------------------------------------->
-->
<channel name="xsettings" version="1.0">
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>
@ -117,11 +117,11 @@ Processed template files:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/template
------------------------------------------------------------------------------->
-->
<channel name="xsettings" version="1.0">
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>
@ -137,11 +137,11 @@ Processed template files:
def test_if_input_documents_are_an_original_document_with_calculate_header_and_a_template_the_add_header_flag_is_set_and_the_already_changed_flag_is_set__the_format_object_joins_an_original_document_and_a_template_and_adds_the_calculate_header_with_a_template_paths_from_the_old_header_and_paths_to_a_current_template(self):
original_text = '''<?xml version="1.0" encoding="UTF-8"?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
------------------------------------------------------------------------------->
-->
<channel name="xsettings" version="1.0">
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>
@ -159,12 +159,12 @@ Processed template files:
'''
join_result = '''<?xml version='1.0' encoding='UTF-8'?>
<!------------------------------------------------------------------------------
<!--
Modified by Calculate Utilities 4.0
Processed template files:
/path/to/ancient/template
/path/to/template
------------------------------------------------------------------------------->
-->
<channel name="xsettings" version="1.0">
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>

Loading…
Cancel
Save