Skip to content

Commit ab6daf7

Browse files
author
Martin
committed
Fixed PR comments
1 parent b0f514d commit ab6daf7

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

converter_app/readers/xml_reader.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ def _generate_data_table(self, shape: list[str], xml_path: str, text_array: list
4747
'node': node
4848
}
4949

50-
def _handle_node(self, node: ET.Element, xml_path: str, node_name: str):
50+
def handle_node(self, node: ET.Element, xml_path: str, node_name: str):
51+
"""
52+
This method can be overridden to handle special nodes separately.
53+
54+
:param node: XML node Object
55+
:param xml_path: Path in global XML-file to this node
56+
:param node_name: Name of the Node
57+
"""
5158
pass
5259

5360
def _add_metadata(self, key: str, val: any, node: ET.Element):
@@ -73,7 +80,7 @@ def _read_node(self, node: ET.Element, xml_path: str = '#'):
7380
new_path = 'Unknown'
7481
local_name = ''
7582

76-
self._handle_node(child, xml_path, local_name)
83+
self.handle_node(child, xml_path, local_name)
7784

7885
if text is not None and not self._filter_data_rows(child, text, new_path):
7986
self._add_metadata(new_path, text.strip(), node)
@@ -84,20 +91,11 @@ def _read_node(self, node: ET.Element, xml_path: str = '#'):
8491

8592
def prepare_tables(self):
8693
tables = []
87-
# xml_str = re.sub(r'\sxmlns\s*([:=])', r' xmlns_removed\g<1>', self.file.string)
8894
self._table = self.append_table(tables)
8995
root = ET.XML(self.file.content)
90-
# self._read_node(root)
91-
# root = etree.XML(self.file.content)
92-
93-
# Remove unused namespace declarations
94-
# ET.cleanup_namespaces(root)
95-
9696
self._read_node(root)
97-
9897
self._merge_tables(self._data_tables, tables)
9998

100-
10199
potential_tables = [x for k, x in self._potential_data_tables.items() if len(x['values']) > 1]
102100
potential_tables.sort(key= lambda x : len(x['values']))
103101
self._merge_tables(potential_tables, tables)

converter_app/readers/xrdml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, file: File):
1717
self._file_extensions = ['.xrdml']
1818
self._step_sizes = {}
1919

20-
def _handle_node(self, node: ET.Element, xml_path: str, node_name: str):
20+
def handle_node(self, node: ET.Element, xml_path: str, node_name: str):
2121

2222
try:
2323
if node_name == 'positions':

test_static/test_regex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def is_match(s: str):
5454
("1e", False), # Scientific notation without exponent
5555
5656
# 6. Numbers with Commas (International)
57-
("1,000", True), # Number with commas as thousands separators (invalid)
57+
("1,000", True), # Number with commas as thousands separators
5858
("1,000.5", False), # Mixed usage of commas and dots (invalid)
5959
6060
# 7. Leading and Trailing Spaces

0 commit comments

Comments
 (0)