Skip to content

Commit

Permalink
Updated XML reader: extracting more data tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Oct 9, 2024
1 parent fb89c3c commit 47b05e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions converter_app/readers/xml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _add_metadata(self, key: str, val: any, node: ET.Element):
if key in self._potential_data_tables:
if m and self._potential_data_tables[key] is not None:
self._potential_data_tables[key]['values'].append(self.as_number(val))
self._potential_data_tables[key]['shape'] += 'f'
else:
self._potential_data_tables[key] = None
elif m:
Expand Down Expand Up @@ -94,14 +95,25 @@ def prepare_tables(self):

self._read_node(root)

self._merge_tables(self._data_tables, tables)


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


return tables

def _merge_tables(self, data_tables: list, tables):
current_shape = ''
for table_col in self._data_tables:
for table_col in data_tables:
if current_shape != table_col['shape']:
current_shape = table_col['shape']
self._table = self.append_table(tables)
self._table['rows'] = [[] for x in range(len(table_col['values']))]

tag_name = self._get_tag_name(table_col['node'])
tag_name = self._get_tag_name(table_col['node'])
self._table.add_metadata(f"COL #{len(self._table['rows'][0])}", tag_name)
self._table.add_metadata(f"COL #{len(self._table['rows'][0])} XML PATH", table_col['path'])

Expand All @@ -111,7 +123,5 @@ def prepare_tables(self):
for k, v in table_col['node'].attrib.items():
self._table.add_metadata(f'{tag_name}.{k}', v)

return tables


Readers.instance().register(XMLReader)
2 changes: 1 addition & 1 deletion test_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def generate_test(src_path, file, res_path, _unused):
parser.add_argument('-g', '--github', action='store_true')
args = parser.parse_args()
if args.github or args.expected or args.tests or args.test_profiles or args.expected_profiles:
load_profiles_from_git()
pass #load_profiles_from_git()
if args.tests or args.expected:
TEST_IDX = 0
TEST_DICT = {}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 47b05e8

Please sign in to comment.