From: Anthony Geay Date: Fri, 5 Feb 2021 09:22:15 +0000 (+0100) Subject: Add to med30 convertor. X-Git-Tag: V9_7_0a1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66bc12813f1bc01afb950cbbc11fd94f8f2009ed;p=tools%2Fmedcoupling.git Add to med30 convertor. --- diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index 6ab12c817..e94e1415b 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -107,7 +107,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 ConvertMEDFileTo33.py PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) +INSTALL(FILES ConvertMEDFileTo33.py 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..4a4ef1ce3 --- /dev/null +++ b/src/MEDLoader/Swig/ConvertMEDFileTo30.py @@ -0,0 +1,48 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2021 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 successfully converted to 3.0 ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut))) + pass + +if __name__=="__main__": + import argparse + parser=argparse.ArgumentParser(description='Convert a MED file into a MED file with 3.3 version (3.3.1)') + parser.add_argument('nameOfMEDFile', type=str, nargs=1,help='File name of the MED file to be converted into 3.3.') + args=parser.parse_args() + nameOfMEDFile=args.nameOfMEDFile[0] + ConvertTo30(nameOfMEDFile) + pass