Commit 5aab8903 authored by John Tourtellott's avatar John Tourtellott

Change output spec from single file to directory & filename base

This *should* be backward compatible with previous .crf files
parent ae224029
......@@ -17,6 +17,10 @@
</File>
<String Name="AnalysisTypes" Label="Analysis Types" AdvanceLevel="99" Version="0"
Extensible="true" NumberOfRequiredValues="1"/>
<Directory Name="OutputDirectory" Label="Output Directory" Version="1" NumberOfRequiredValues="1" />
<String Name="FileBase" Label="File Base" Version="1" NumberOfRequiredValues="1">
<BriefDescription="Common base name for output files (.2dm, .bc)" />
</String>
<File Name="PythonScript" Label="Python script" AdvanceLevel="1" Version="0" NumberOfRequiredValues="1"
AdvanceLevel="1" ShouldExist="true"
FileFilters="Python files (*.py);;All files (*.*)">
......
......@@ -152,7 +152,9 @@ def ExportCMB(spec):
# Open output file and start exporting content
completed = False
with open(scope.output_filename, 'w') as scope.output:
bc_filename = scope.output_filebase + '.bc'
bc_path = os.path.join(scope.output_directory, bc_filename)
with open(bc_path, 'w') as scope.output:
scope.output.write('OP SW2\n')
n = len(scope.constituent_dict)
scope.output.write('OP TRN %d\n' % n)
......@@ -178,7 +180,7 @@ def ExportCMB(spec):
# Last line
scope.output.write('END\n')
print 'Wrote', scope.output_filename
print 'Wrote', bc_path
completed = True
if not completed:
......
......@@ -133,7 +133,7 @@ def init_scope(spec):
* manager (smtk::attribute::System)
* export_manager (smtk::attribute::System)
* output_directory
* output_file
* output_filebase == common prefix for output files
'''
scope = ExportScope()
scope.logger = spec.getLogger()
......@@ -152,7 +152,7 @@ def init_scope(spec):
else:
print 'System attributes not associated with model'
scope.output_filename = 'output.bc' # default
scope.output_filebase = 'output' # default
scope.output_directory = os.getcwd() # default
scope.analysis_types = list()
scope.categories = list()
......@@ -168,10 +168,21 @@ def init_scope(spec):
else:
att = att_list[0]
# Legacy/deprecated
item = att.find('OutputFile')
if item is not None:
file_item = smtk.to_concrete(item)
scope.output_filename = file_item.value(0)
filename = file_item.value(0)
scope.output_filebase = os.path.splitext(filename)[0]
scope.output_filename = filename
item = att.find('FileBase')
if item is not None:
string_item = smtk.to_concrete(item)
scope.output_filebase = string_item.value(0)
# String off ending ".bc", in case it was included
if scope.output_filebase.endswith('.bc'):
scope.output_filebase = scope.output_filebase[0:-3]
item = att.find('OutputDirectory')
if item is not None:
......
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