Commit c793bdf9 authored by John Tourtellott's avatar John Tourtellott

Update print statements for py2/3 compatibility in Truchas writer

parent f4bc270a
......@@ -12,8 +12,9 @@
"""
Export operator for Truchas workflows
"""
from __future__ import print_function
import os
print 'loading', os.path.basename(__file__)
print('loading', os.path.basename(__file__))
import sys
sys.dont_write_bytecode
......@@ -43,7 +44,7 @@ class Export(smtk.operation.Operation):
try:
success = ExportCMB(self)
except:
print 'Error', self.log().convertToString()
print('Error', self.log().convertToString())
#smtk.ErrorMessage(self.log(), sys.exc_info()[0])
raise
return self.createResult(smtk.operation.Operation.Outcome.FAILED)
......@@ -55,16 +56,16 @@ class Export(smtk.operation.Operation):
def createSpecification(self):
spec = self.createBaseSpecification()
print 'spec:', spec
print('spec:', spec)
# Load export atts
source_dir = os.path.abspath(os.path.dirname(__file__))
print 'source_dir:', source_dir
print('source_dir:', source_dir)
sbt_path = os.path.join(source_dir, 'internal', 'truchas-export.sbt')
print 'sbt_path:', sbt_path
print('sbt_path:', sbt_path)
reader = smtk.io.AttributeReader()
result = reader.read(spec, sbt_path, self.log())
print 'reader result:', result
print('reader result:', result)
# opDef = spec.createDefinition('test op', 'operation')
opDef = spec.findDefinition('truchas-export')
......@@ -407,9 +408,9 @@ def ExportCMB(export_op):
if not project_name:
project_name = 'truchas'
msg = 'No Project Name specified; using \"%s\"' % project_name
print 'WARNING:', msg
print('WARNING:', msg)
logger.addWarning(msg)
print 'project_name', project_name
print('project_name', project_name)
project_name = project_name
# Initialize project path (folder)
......@@ -418,12 +419,12 @@ def ExportCMB(export_op):
if item is not None:
dir_item = item
project_path = dir_item.value(0)
print 'project_path', project_path
print('project_path', project_path)
if not project_path:
project_path = os.getcwd()
msg = 'No project_path specified -- using', project_path
print 'ERROR:', msg
print('ERROR:', msg)
logger.addWarning(msg)
return False
......@@ -435,7 +436,7 @@ def ExportCMB(export_op):
model_entity = smtk.model.Entity.CastTo(operator_spec.find('model').objectValue(0))
write_mesh_op = smtk.session.mesh.Export.create()
if write_mesh_op is None:
print 'MESH OPERATOR IS NONE'
print('MESH OPERATOR IS NONE')
mesh_filename = 'NOT-FOUND'
else:
mesh_filename = project_name + ".exo"
......@@ -456,6 +457,6 @@ def ExportCMB(export_op):
output_path = os.path.join(project_path, output_filename)
truchas_writer = writer.Writer(operator_spec, logger, mesh_filename)
completed = truchas_writer.write(output_path, namelist_sequence, format_table)
print 'Writer completion status %s' % completed
print('Writer completion status %s' % completed)
sys.stdout.flush()
return completed
......@@ -9,8 +9,9 @@
# PURPOSE. See the above copyright notice for more information.
#
#=============================================================================
from __future__ import print_function
import os
print 'loading', os.path.basename(__file__)
print('loading', os.path.basename(__file__))
import sys
import smtk
......@@ -18,7 +19,7 @@ import smtk.attribute
# Workaround for missing enum
if not hasattr(smtk.attribute.Item, 'ReferenceType'):
print 'Adding smtk.attribute.Item.ReferenceType'
print('Adding smtk.attribute.Item.ReferenceType')
smtk.attribute.Item.ReferenceType = 13
# ---------------------------------------------------------------------
......@@ -109,7 +110,7 @@ class CardFormat:
'''Writes card for input attribute
'''
if self.is_custom:
print 'WARNING: Ignoring custom card for keyword', self.keyword
print('WARNING: Ignoring custom card for keyword', self.keyword)
return False
# Skip cards with conditions that don't match
......@@ -137,8 +138,8 @@ class CardFormat:
full_item_path = '/'.join([base_item_path, self.item_path])
item = att.itemAtPath(full_item_path, '/')
if item is None:
print 'ERROR: item not found for attribute %s path %s' % \
(att.name(), full_item_path)
print('ERROR: item not found for attribute %s path %s' % \
(att.name(), full_item_path))
return False
if item.type() == smtk.attribute.Item.VoidType:
......
......@@ -9,8 +9,9 @@
# PURPOSE. See the above copyright notice for more information.
#
#=============================================================================
from __future__ import print_function
import os
print 'loading', os.path.basename(__file__)
print('loading', os.path.basename(__file__))
import sys
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment