def saveTemplate(self, filename=None, template_options=None): ''' Save the project as a YAML formatted file. Uses the filename stored in opts['configure']['output prefix'], use setConfigureOption('output prefix',f) to set this name. ''' if filename is None: filename = self.opts['configure']['output prefix'] + '.yml' from pywst.common.wst_config import Path _SPE = True Path.SuppressPathExpansion, _SPE = _SPE, Path.SuppressPathExpansion try: fid = open(filename, 'wt') templ = ConfigBlock("%s configuration template" % self.module) for k in self.module_blocks: templ.declare(k, self.opts[k]()) if template_options is not None: templ.set_value(template_options) fid.write(templ.generate_yaml_template(indent_spacing=2, width=95)) fid.close() except: print 'Error saving "%s"' % filename raise finally: Path.SuppressPathExpansion, _SPE = _SPE, Path.SuppressPathExpansion print "Writing template file " + filename return True
def saveVisOutput(self, outfilename, config, module_blocks, template_options): fid = open(outfilename, 'wt') templ = ConfigBlock("# YML input file for visualization") for k in module_blocks: templ.declare(k, config[k]()) if template_options is not None: templ.set_value(template_options) fid.write(templ.generate_yaml_template(indent_spacing=2, width=95)) fid.close()
def saveOutput(self, outfilename, config, module_blocks, template_options): fid = open(outfilename, 'wt') templ = ConfigBlock("%s output" % self.module) for k in module_blocks: templ.declare(k, config[k]()) if template_options is not None: templ.set_value(template_options) if self.opts['configure']['debug']: fid.write('---\n') fid.write(templ.generate_yaml_template(indent_spacing=2, width=95)) if self.opts['configure']['debug']: fid.write('---\n') fid.write("#%s input\n" % self.module) out = self.opts.display(content_filter='userdata') fid.write(out) fid.close()