def negative_parser_main(): usage = """ Usage: ./negative_parser.py <negative XES LOG filename> [--verbose][--debug] """ if not check_argv(sys.argv, minimum=1, maximum=4): print usage ret = -1 else: ret = 0 try: filename = sys.argv[1] if not filename.endswith('.xes'): print filename, ' does not end in .xes. It should...' raise Exception('Filename has wrong extension') if not isfile(filename): raise Exception("El archivo especificado no existe") if '--debug' in sys.argv: pdb.set_trace() obj = NegativeParser(filename, verbose='--verbose' in sys.argv) obj.parse() if '--verbose' in sys.argv: print 'Parse done. Calcuting Parikhs vector' obj.parikhs_vector() print 'Se encontraron {0} puntos en un espacio de dimensión {1}'.format( len(obj.pv_set), obj.dim) if '--verbose' in sys.argv: print "#"*15 except Exception, err: ret = 1 if hasattr(err, 'message'): print 'Error: ', err.message else: print 'Error: ', err raise err return ret
def parse_negatives(self): if not self.nfilename: logger.error('No se ha especificado un archivo '\ 'de trazas negativas!') raise Exception('No se ha especificado un archivo '\ 'de trazas negativas!') if self.verbose: print 'Starting parse of negative traces\n' start_time = time.time() if self.nfilename.endswith('.xes'): parser = NegativeParser(self.nfilename, required_dimension=self.dim, event_dictionary=self.event_dictionary) elif self.filename.endswith('.txt'): raise Exception('Not implemented yet!') else: logger.error("Error in file %s extension. Only '.xes'"\ " is allowed!",(self.nfilename or '')) raise Exception("Error in file %s extension. Only '.xes'"\ " is allowed!"%(self.nfilename or '')) parser.parikhs_vector() self.npv_traces = parser.pv_traces self.npv_set = parser.pv_set self.npv_array = parser.pv_array if self.verbose: print 'Parse of negative traces done\n' elapsed_time = time.time() - start_time print '# RESULTADO obtenido en: ', elapsed_time print '#'*40+'\n'
def parse_negatives(self): if not self.nfilename: logger.error('No se ha especificado un archivo '\ 'de trazas negativas!') raise Exception('No se ha especificado un archivo '\ 'de trazas negativas!') if self.nfilename.endswith('.xes'): parser = NegativeParser(self.nfilename, required_dimension=self.dim, event_dictionary=self.event_dictionary) elif self.filename.endswith('.txt'): raise Exception('Not implemented yet!') else: logger.error("Error in file %s extension. Only '.xes'"\ " is allowed!",(self.nfilename or '')) raise Exception("Error in file %s extension. Only '.xes'"\ " is allowed!"%(self.nfilename or '')) parser.parikhs_vector() self.npv_traces = parser.pv_traces self.npv_set = parser.pv_set self.npv_array = parser.pv_array