@@ -233,35 +233,29 @@ def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue, printJobMo
233
233
234
234
class FilamentCSVFormattorParser :
235
235
236
- def formatValue (self , printJob , fieldNames ):
237
-
238
- if (hasattr (printJob , fieldNames [0 ]) == False ):
239
- return "-"
240
- allFilamentModels = getattr (printJob , fieldNames [0 ])
241
- if (allFilamentModels is None ):
242
- allFilamentModels = printJob .filaments
236
+ def formatValue (self , printJob , fieldName ):
243
237
244
- if (allFilamentModels is None or len (allFilamentModels ) == 0 ):
238
+ # only support for total model
239
+ totalFilamentModel = printJob .getFilamentModelByToolId ("total" )
240
+ if (totalFilamentModel == None ):
245
241
return "-"
246
- # only support for one model
247
- filamentModel = allFilamentModels [0 ]
248
- if (hasattr (filamentModel , fieldNames [1 ]) == False ):
242
+ if (hasattr (totalFilamentModel , fieldName ) == False ):
249
243
return "-"
250
- valueToFormat = getattr (filamentModel , fieldNames [ 1 ] )
244
+ valueToFormat = getattr (totalFilamentModel , fieldName )
251
245
252
246
# append unit to value
253
- if ("usedCost" == fieldNames [ 1 ] and valueToFormat != None and valueToFormat != "" ):
254
- if ( hasattr ( filamentModel , "spoolCostUnit" ) == True and filamentModel . spoolCostUnit != None ):
255
- valueToFormat = StringUtils . formatFloatSave ( StringUtils . FLOAT_DEFAULT_FORMAT , valueToFormat , "-" )
247
+ if ("usedCost" == fieldName and valueToFormat != None and valueToFormat != "" ):
248
+ valueToFormat = StringUtils . formatFloatSave ( StringUtils . FLOAT_DEFAULT_FORMAT , valueToFormat , "-" )
249
+ if ( hasattr ( totalFilamentModel , "spoolCostUnit" ) == True and totalFilamentModel . spoolCostUnit != None ):
256
250
if (valueToFormat != "-" ):
257
- if (isinstance (filamentModel .spoolCostUnit , str )):
258
- valueToFormat = valueToFormat + filamentModel .spoolCostUnit
251
+ if (isinstance (totalFilamentModel .spoolCostUnit , str )):
252
+ valueToFormat = valueToFormat + totalFilamentModel .spoolCostUnit
259
253
else :
260
- valueToFormat = valueToFormat + filamentModel .spoolCostUnit .encode ("utf-8" )
254
+ valueToFormat = valueToFormat + totalFilamentModel .spoolCostUnit .encode ("utf-8" )
261
255
262
- if ("usedLength" == fieldNames [ 1 ] or
263
- "calculatedLength" == fieldNames [ 1 ] or
264
- "usedWeight" == fieldNames [ 1 ] ):
256
+ if ("usedLength" == fieldName or
257
+ "calculatedLength" == fieldName or
258
+ "usedWeight" == fieldName ):
265
259
266
260
if (valueToFormat != None and valueToFormat != "" and valueToFormat != "-" ):
267
261
valueToFormat = StringUtils .formatFloatSave (StringUtils .FLOAT_DEFAULT_FORMAT , valueToFormat , "-" )
@@ -370,15 +364,15 @@ def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue, printJobMo
370
364
COLUMN_HEIGHT : CSVColumn ("printedHeight" , COLUMN_HEIGHT , "" , DefaultCSVFormattorParser ()),
371
365
COLUMN_NOTE : CSVColumn ("noteText" , COLUMN_NOTE , "" , DefaultCSVFormattorParser ()),
372
366
COLUMN_TEMPERATURES : CSVColumn ("allTemperatures" , COLUMN_TEMPERATURES , "" , TemperaturCSVFormattorParser ()),
373
- COLUMN_SPOOL_VENDOR : CSVColumn ([ "allFilaments" , " vendor"] , COLUMN_SPOOL_VENDOR , "" , FilamentCSVFormattorParser ()),
374
- COLUMN_SPOOL_NAME : CSVColumn ([ "allFilaments" , " spoolName"] , COLUMN_SPOOL_NAME , "" , FilamentCSVFormattorParser ()),
375
- COLUMN_MATERIAL : CSVColumn ([ "allFilaments" , " material"] , COLUMN_MATERIAL , "" , FilamentCSVFormattorParser ()),
376
- COLUMN_DIAMETER : CSVColumn ([ "allFilaments" , " diameter"] , COLUMN_DIAMETER , "" , FilamentCSVFormattorParser ()),
377
- COLUMN_DENSITY : CSVColumn ([ "allFilaments" , " density"] , COLUMN_DENSITY , "" , FilamentCSVFormattorParser ()),
378
- COLUMN_USED_LENGTH : CSVColumn ([ "allFilaments" , " usedLength"] , COLUMN_USED_LENGTH , "" , FilamentCSVFormattorParser ()),
379
- COLUMN_CALCULATED_LENGTH : CSVColumn ([ "allFilaments" , " calculatedLength"] , COLUMN_CALCULATED_LENGTH , "" , FilamentCSVFormattorParser ()),
380
- COLUMN_USED_WEIGHT : CSVColumn ([ "allFilaments" , " usedWeight"] , COLUMN_USED_WEIGHT , "" , FilamentCSVFormattorParser ()),
381
- COLUMN_USED_FILAMENT_COSTS : CSVColumn ([ "allFilaments" , " usedCost"] , COLUMN_USED_FILAMENT_COSTS , "" , FilamentCSVFormattorParser ()),
367
+ COLUMN_SPOOL_VENDOR : CSVColumn (" vendor" , COLUMN_SPOOL_VENDOR , "" , FilamentCSVFormattorParser ()),
368
+ COLUMN_SPOOL_NAME : CSVColumn (" spoolName" , COLUMN_SPOOL_NAME , "" , FilamentCSVFormattorParser ()),
369
+ COLUMN_MATERIAL : CSVColumn (" material" , COLUMN_MATERIAL , "" , FilamentCSVFormattorParser ()),
370
+ COLUMN_DIAMETER : CSVColumn (" diameter" , COLUMN_DIAMETER , "" , FilamentCSVFormattorParser ()),
371
+ COLUMN_DENSITY : CSVColumn (" density" , COLUMN_DENSITY , "" , FilamentCSVFormattorParser ()),
372
+ COLUMN_USED_LENGTH : CSVColumn (" usedLength" , COLUMN_USED_LENGTH , "" , FilamentCSVFormattorParser ()),
373
+ COLUMN_CALCULATED_LENGTH : CSVColumn (" calculatedLength" , COLUMN_CALCULATED_LENGTH , "" , FilamentCSVFormattorParser ()),
374
+ COLUMN_USED_WEIGHT : CSVColumn (" usedWeight" , COLUMN_USED_WEIGHT , "" , FilamentCSVFormattorParser ()),
375
+ COLUMN_USED_FILAMENT_COSTS : CSVColumn (" usedCost" , COLUMN_USED_FILAMENT_COSTS , "" , FilamentCSVFormattorParser ()),
382
376
}
383
377
384
378
0 commit comments