allow '.' in filenames
This commit is contained in:
parent
b8503e84b7
commit
ae959b9cc2
|
@ -197,11 +197,10 @@ class VTK:
|
||||||
elif isinstance(self.vtk_data,vtk.vtkPolyData):
|
elif isinstance(self.vtk_data,vtk.vtkPolyData):
|
||||||
writer = vtk.vtkXMLPolyDataWriter()
|
writer = vtk.vtkXMLPolyDataWriter()
|
||||||
|
|
||||||
default_ext = writer.GetDefaultFileExtension()
|
default_ext = '.'+writer.GetDefaultFileExtension()
|
||||||
ext = Path(fname).suffix
|
ext = Path(fname).suffix
|
||||||
if ext and ext != '.'+default_ext:
|
writer.SetFileName(str(fname)+default_ext if default_ext != ext else '')
|
||||||
raise ValueError(f'Given extension "{ext}" does not match default ".{default_ext}"')
|
|
||||||
writer.SetFileName(str(Path(fname).with_suffix('.'+default_ext)))
|
|
||||||
if compress:
|
if compress:
|
||||||
writer.SetCompressorTypeToZLib()
|
writer.SetCompressorTypeToZLib()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -85,6 +85,12 @@ class TestVTK:
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('fname',['a','a.vtp','a.b','a.b.vtp'])
|
||||||
|
def test_filename_variations(self,tmp_path,fname):
|
||||||
|
points = np.random.rand(102,3)
|
||||||
|
v = VTK.from_poly_data(points)
|
||||||
|
v.save(tmp_path/fname)
|
||||||
|
|
||||||
@pytest.mark.parametrize('name,dataset_type',[('this_file_does_not_exist.vtk', None),
|
@pytest.mark.parametrize('name,dataset_type',[('this_file_does_not_exist.vtk', None),
|
||||||
('this_file_does_not_exist.vtk','vtk'),
|
('this_file_does_not_exist.vtk','vtk'),
|
||||||
('this_file_does_not_exist.vtx', None)])
|
('this_file_does_not_exist.vtx', None)])
|
||||||
|
|
Loading…
Reference in New Issue