1 # Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
23 def changeTab(theLine):
24 aResult = theLine.split("#")[0].replace("\t"," ")
25 aResult += theLine[len(aResult):]
28 def importParameters(theDocument, theFileName):
32 aFile = codecs.open(theFileName, 'r', encoding = 'utf_8_sig')
34 print("Failed to read file: %s" % str(e))
38 aLine = aLine.rstrip("\n")
39 aLine = changeTab(aLine)
45 aFirstText = aLine.split(" ")[0]
47 aName = aFirstText.split("#")[0].strip()
49 aLine = aLine.lstrip(aName)
51 aParameter = aLine.split("#")[0]
53 aLine = aLine.lstrip(aParameter)
54 aLine = aLine.lstrip("#")
60 aResult.append(model.addParameter(theDocument, aName, aParameter.strip(), aComment.strip()))
61 except SyntaxError as anError:
62 print(anError, file = sys.stderr)