Skip to content

Commit

Permalink
Merge branch '100-new-powerxrd-reader' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Oct 11, 2024
2 parents 6588aee + 45a615f commit 05b1136
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
13 changes: 8 additions & 5 deletions converter_app/readers/uxd_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class UXDReader(Reader):
identifier = 'uxd_reader'
priority = 10



def __init__(self, file: File):
super().__init__(file)
self._file_extensions = ['.uxd']
Expand All @@ -42,6 +40,11 @@ def _read_data(self, line: str):
except ValueError:
pass

def _add_metadata(self, key, val):
if self.float_pattern.fullmatch(val):
val = self.get_value(val)
self._table.add_metadata(key, val)

def prepare_tables(self):
tables = []
tables = []
Expand All @@ -57,7 +60,7 @@ def prepare_tables(self):
data = line.split('=')
key = data[0].strip()[1:]
value = data[1].strip().replace('\n', '')
self._table.add_metadata(key, value)
self._add_metadata(key, value)
else:
data_rows.append(line)
try:
Expand All @@ -69,11 +72,11 @@ def prepare_tables(self):
self._read_data(row)

if 'START' in self._table['metadata'] and 'STEPSIZE' in self._table['metadata']:
end = self.as_number(self._table['metadata']['START']) + (self.as_number(self._table['metadata']['STEPSIZE']) * (len(self._table['rows']) - 1))
end = self.as_number(self._table['metadata']['START']) + (
self.as_number(self._table['metadata']['STEPSIZE']) * (len(self._table['rows']) - 1))
self._table.add_metadata("END", end)

return tables


Readers.instance().register(UXDReader)

13 changes: 7 additions & 6 deletions converter_app/readers/xrdml.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ def _prepare_step_size(self, col_length, table):
if mt_p.startswith(path):
for v in values:
if 'endPosition' in v and 'startPosition' in v:
step_size = (v['endPosition'] - v['startPosition']) / (len(table['rows']) - 1)
table.add_metadata(f'COL #{col_length}.stepSize', step_size)
table.add_metadata(f'COL #{col_length}.startPosition', v['startPosition'])
table.add_metadata(f'COL #{col_length}.endPosition', v['endPosition'])
table.add_metadata(f'COL #{col_length}.unit', v['unit'])
table.add_metadata(f'COL #{col_length}.axis', v['axis'])
col_length += 1
step_size = (v['endPosition'] - v['startPosition']) / (len(self._table['rows']) - 1)
self._table.add_metadata(f'COL #{col_length}.stepSize', step_size)
self._table.add_metadata(f'COL #{col_length}.startPosition', v['startPosition'])
self._table.add_metadata(f'COL #{col_length}.endPosition', v['endPosition'])
self._table.add_metadata(f'COL #{col_length}.unit', v['unit'])
self._table.add_metadata(f'COL #{col_length}.axis', v['axis'])

def prepare_tables(self):
tables = super().prepare_tables()
for table in tables:
Expand Down

Large diffs are not rendered by default.

0 comments on commit 05b1136

Please sign in to comment.