From: Anthony Geay Date: Mon, 7 Nov 2016 07:25:37 +0000 (+0100) Subject: Useful ConvertMEDFileTo30 tool to change version of a file. X-Git-Tag: V8_2_0a1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f68199ac9e95b893fa622994f894e4f0e7bab55b;p=tools%2Fmedcoupling.git Useful ConvertMEDFileTo30 tool to change version of a file. --- diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index ed4a1ef67..14d39353a 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -78,6 +78,7 @@ INSTALL(FILES med2sauv PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EX INSTALL(FILES sauv2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) INSTALL(FILES case2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) INSTALL(FILES med2case PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) +INSTALL(FILES ConvertMEDFileTo30.py PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) diff --git a/src/MEDLoader/Swig/ConvertMEDFileTo30.py b/src/MEDLoader/Swig/ConvertMEDFileTo30.py new file mode 100644 index 000000000..88f523354 --- /dev/null +++ b/src/MEDLoader/Swig/ConvertMEDFileTo30.py @@ -0,0 +1,48 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author : Anthony GEAY (EDF R&D) + +import MEDLoader as ml +import os + +def ConvertTo30(nameOfMEDFile): + fn,ext=os.path.splitext(nameOfMEDFile) + assert(ext in [".med",".rmed"]) + realFnOut=fn+"_30.med" + # + initalVersion=ml.MEDFileVersionOfFileStr(nameOfMEDFile) + # + mfd=ml.MEDFileData(nameOfMEDFile) + mfd.write30(realFnOut,2) + # + finalVersion=ml.MEDFileVersionOfFileStr(realFnOut) + # + print("File \"%s\" has been converted to 3.0 successfuly ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut)) + pass + +if __name__=="__main__": + import argparse + parser=argparse.ArgumentParser(description=u'Convert a MED file into a MED file with 3.0 version (3.0.8)') + parser.add_argument('nameOfMEDFile', type=str, nargs=1,help='File name of the MED file to be converted into 3.0.') + args=parser.parse_args() + nameOfMEDFile=args.nameOfMEDFile[0] + ConvertTo30(nameOfMEDFile) + pass