From 892b7eee98c5e4fba29b486799dbe62023a834f9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 17:34:31 +0100 Subject: [PATCH] consistency check and new test --- PRIVATE | 2 +- python/damask/ktv.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PRIVATE b/PRIVATE index c5683e828..05ac971ce 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit c5683e828c9a761ad046926e26d6cc6cc10c355c +Subproject commit 05ac971ce58fc399dd99be9151b7d61d049aec42 diff --git a/python/damask/ktv.py b/python/damask/ktv.py index e0b0982a2..1d2072ef2 100644 --- a/python/damask/ktv.py +++ b/python/damask/ktv.py @@ -158,7 +158,6 @@ class VTK: return VTK(geom) - # ToDo: If extension is given, check for consistency. def write(self,fname): """ Write to file. @@ -176,8 +175,11 @@ class VTK: elif(isinstance(self.geom,vtk.vtkPolyData)): writer = vtk.vtkXMLPolyDataWriter() - writer.SetFileName('{}.{}'.format(os.path.splitext(fname)[0], - writer.GetDefaultFileExtension())) + default_ext = writer.GetDefaultFileExtension() + name, ext = os.path.splitext(fname) + if ext and ext != default_ext: + raise ValueError('Given extension {} is not {}'.format(ext,default_ext)) + writer.SetFileName('{}.{}'.format(name,default_ext)) writer.SetCompressorTypeToZLib() writer.SetDataModeToBinary() writer.SetInputData(self.geom)