Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Nov 13, 2024
1 parent 8d49b1b commit edddce7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions lib/galaxy/datatypes/constructive_solid_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,18 +813,19 @@ def get_next_line(fh):
fh.readline()
return line.strip()


class VtkXml(GenericXml):
"""Format for defining VTK (XML based) and its sub-datatypes. https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html"""

edam_format = "edam:format_2332"
file_ext = "vtkxml"

#The same MetadataElements are also available for legacy VTK datatypes.
# The same MetadataElements are also available for legacy VTK datatypes.
MetadataElement(name="vtk_version", default=None, desc="Vtk version", readonly=True, optional=True, visible=True)
MetadataElement(name="file_format", default=None, desc="File format", readonly=True, optional=True, visible=True)
MetadataElement(name="dataset_type", default=None, desc="Dataset type", readonly=True, optional=True, visible=True)

def extract_version(self, line: str) -> str:
def extract_version(self, line: str) -> str:
match = re.search(r'version="([^"]+)"', line)
if match:
return match.group(1)
Expand All @@ -843,10 +844,9 @@ def set_meta(self, dataset: DatasetProtocol, **kwd) -> None:
first_line = file.readline()
if first_line.startswith("<?xml"):
first_line = file.readline()
dataset.metadata.vtk_version = self.extract_version(first_line)
dataset.metadata.vtk_version = self.extract_version(first_line)
dataset.metadata.dataset_type = self.extract_type(first_line)



def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
"""Set the peek and blurb text for VTK dataset files."""
if not dataset.dataset.purged:
Expand All @@ -868,4 +868,3 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
False
"""
return self._has_root_element_in_prefix(file_prefix, "VTKFile")

20 changes: 10 additions & 10 deletions test/unit/data/datatypes/test_constructive_solid_geometry.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

from galaxy.datatypes.constructive_solid_geometry import VtkXml
from galaxy.datatypes.constructive_solid_geometry import VtkXml
from .util import (
get_input_files,
MockDataset,
)


def test_vtkXml_set_meta():
vtkXml = VtkXml()
with get_input_files("data.vtu") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])
vtkXml = VtkXml()
with get_input_files("data.vtu") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])

vtkXml.set_meta(dataset)
vtkXml.set_meta(dataset)

assert dataset.metadata.vtk_version == "0.1"
assert dataset.metadata.file_format == "XML"
assert dataset.metadata.dataset_type == "UnstructuredGrid"
assert dataset.metadata.vtk_version == "0.1"
assert dataset.metadata.file_format == "XML"
assert dataset.metadata.dataset_type == "UnstructuredGrid"

0 comments on commit edddce7

Please sign in to comment.