From 4f36439028690e5d941a033bd55469e4ef4df6b3 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 21 Apr 2015 21:00:01 +0100 Subject: [PATCH] Material: Fix white space errors in Material.py Signed-off-by: Przemo Firszt --- src/Mod/Material/Material.py | 45 +++++++++++++++--------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/Mod/Material/Material.py b/src/Mod/Material/Material.py index 19100d0f3c8f..f83bfec5191f 100644 --- a/src/Mod/Material/Material.py +++ b/src/Mod/Material/Material.py @@ -1,6 +1,6 @@ #*************************************************************************** #* * -#* Copyright (c) 2013 - Juergen Riegel * +#* Copyright (c) 2013-2015 - Juergen Riegel * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * @@ -20,20 +20,15 @@ #* * #*************************************************************************** - - - - - # here the usage description if you use this tool from the command line ("__main__") CommandlineUsage = """Material - Tool to work with FreeCAD Material definition cards Usage: Material [Options] card-file-name - + Options: -c, --output-csv=file-name write a comma seperated grid with the material data - + Exit: 0 No Error or Warning found 1 Argument error, wrong or less Arguments given @@ -41,18 +36,19 @@ Tool to work with FreeCAD Material definition cards Examples: - - Material "StandardMaterial/Steel.FCMat" - + + Material "StandardMaterial/Steel.FCMat" + Autor: (c) 2013 Juergen Riegel - mail@juergen-riegel.net + mail@juergen-riegel.net Licence: LGPL Version: 0.1 """ + def importFCMat(fileName): "Read a FCMat file into a dictionary" import ConfigParser @@ -66,12 +62,14 @@ def importFCMat(fileName): dict1[option] = Config.get(section, option) return dict1 - + + def exportFCMat(fileName,matDict): "Write a material dictionary to a FCMat file" - import ConfigParser,string + import ConfigParser + import string Config = ConfigParser.ConfigParser() - + # create groups for x in matDict.keys(): grp,key = string.split(x,sep='_') @@ -82,19 +80,17 @@ def exportFCMat(fileName,matDict): for x in matDict.keys(): grp,key = string.split(x,sep='_') Config.set(grp,key,matDict[x]) - + Preamble = "# This is a FreeCAD material-card file\n\n" # Writing our configuration file to 'example.cfg' with open(fileName, 'wb') as configfile: configfile.write(Preamble) Config.write(configfile) - - - - + if __name__ == '__main__': - import sys, getopt + import sys + import getopt try: opts, args = getopt.getopt(sys.argv[1:], "c:", ["output-csv="]) except getopt.GetoptError: @@ -105,7 +101,7 @@ def exportFCMat(fileName,matDict): # checking on the options for o, a in opts: if o in ("-c", "--output-csv"): - print "writing file: " + a +"\n" + print "writing file: " + a + "\n" OutPath = a # runing through the files @@ -114,7 +110,4 @@ def exportFCMat(fileName,matDict): kv_map = importFCMat(FileName) for k in kv_map.keys(): print `k` + " : " + `kv_map[k]` - sys.exit(0) # no error - - - + sys.exit(0) # no error