def do_output(self, line): """Main commands: Initialize a new Template or reinitialize one""" args = self.split_arg(line) # Check Argument validity self.check_output(args) noclean = '-noclean' in args force = '-f' in args nojpeg = '-nojpeg' in args main_file_name = "" try: main_file_name = args[args.index('-name') + 1] except Exception: pass self.options['group_subprocesses'] = False # initialize the writer if self._export_format in ['NLO']: self._curr_exporter = export_v4.ExportV4Factory(\ self, noclean, output_type='amcatnlo') # check if a dir with the same name already exists if not force and not noclean and os.path.isdir(self._export_dir)\ and self._export_format in ['NLO']: # Don't ask if user already specified force or noclean logger.info('INFO: directory %s already exists.' % self._export_dir) logger.info('If you continue this directory will be deleted and replaced.') answer = self.ask('Do you want to continue?', 'y', ['y','n'], timeout=self.options['timeout']) if answer != 'y': raise self.InvalidCmd('Stopped by user request') # if one gets here either used -f or answered yes to the question about # removing the dir if os.path.exists(self._export_dir): shutil.rmtree(self._export_dir) # Make a Template Copy if self._export_format in ['NLO']: self._curr_exporter.copy_fkstemplate() # Reset _done_export, since we have new directory self._done_export = False # Perform export and finalize right away self.export(nojpeg, main_file_name) # Automatically run finalize self.finalize(nojpeg) # Generate the virtuals if from OLP if self.options['OLP']!='MadLoop': self._curr_exporter.generate_virtuals_from_OLP( self._curr_matrix_elements,self._export_dir,self.options['OLP']) # Remember that we have done export self._done_export = (self._export_dir, self._export_format) # Reset _export_dir, so we don't overwrite by mistake later self._export_dir = None
def do_output(self, line): """Main commands:Initialize a new Template or reinitialize one""" args = self.split_arg(line) # Check Argument validity self.check_output(args) noclean = '-noclean' in args force = '-f' in args nojpeg = '-nojpeg' in args main_file_name = "" try: main_file_name = args[args.index('-name') + 1] except Exception: pass # Whatever the format we always output the quadruple precision routines # to allow for curing possible unstable points. aloha_original_quad_mode = aloha.mp_precision aloha.mp_precision = True if self._export_format not in self.supported_ML_format: raise self.InvalidCmd('ML5 only support "%s" as export format.' % \ ''.join(self.supported_ML_format)) if not os.path.isdir(self._export_dir) and self._export_format in [ 'matrix' ]: raise self.InvalidCmd('Specified export directory %s does not exist.'\ %str(self._export_dir)) if not force and not noclean and os.path.isdir(self._export_dir)\ and self._export_format.startswith('standalone'): # Don't ask if user already specified force or noclean logger.info('INFO: directory %s already exists.' % self._export_dir) logger.info('If you continue this directory will be cleaned') answer = self.ask('Do you want to continue?', 'y', ['y', 'n']) if answer != 'y': raise self.InvalidCmd('Stopped by user request') else: try: shutil.rmtree(self._export_dir) except OSError: raise self.InvalidCmd('Could not remove directory %s.'\ %str(self._export_dir)) if self._export_format.startswith('standalone'): output_type = 'madloop' elif self._export_format == 'matchbox': output_type = 'madloop_matchbox' self._curr_exporter = export_v4.ExportV4Factory(self, \ noclean, output_type=output_type, group_subprocesses=False) if self._export_format in ['standalone', 'matchbox']: self._curr_exporter.copy_v4template( modelname=self._curr_model.get('name')) if self._export_format == "standalone_rw": self._export_format = "standalone" self._curr_exporter.copy_v4template( modelname=self._curr_model.get('name')) self._export_format = "standalone_rw" # Reset _done_export, since we have new directory self._done_export = False # Perform export and finalize right away self.ML5export(nojpeg, main_file_name) # Automatically run finalize self.ML5finalize(nojpeg) # Remember that we have done export self._done_export = (self._export_dir, self._export_format) # Reset _export_dir, so we don't overwrite by mistake later self._export_dir = None # Put aloha back in its original mode. aloha.mp_precision = aloha_original_quad_mode