def load_source(self, filename, annfile=None, reset=False): if annfile is None: annfile = filename + ".ann" else: print "Loading different annfile %s" % annfile if not os.path.exists(annfile): print "Annotation file (%s) does not exist for %s" % (annfile, filename) if reset: self.app.logen.annotate_file(filename, mode='auto_bta') else: ans = ask_NoAnnfileDialog(master=self.app, Filename=filename) if ans == "simple": print "Simple BTA" if not self.app.logen.annotate_file(filename): complain_loudly( master=self.app, msg="Could not create annotation file!") elif ans == "reset": #self.app.reset_bta_file(self,filename=filename) #return self.app.logen.annotate_file(filename, mode='auto_bta') else: fd = open(filename + ".ann", "w") fd.write("% Empty annotation file") fd.close() starttime = time.time() (anns, syntax, filter, filsyntax) = self.app.logen.get_annotations(filename, annfile) print "Get annotations ", (time.time() - starttime), "seconds" #save anns for safety checks... self.anns = anns self.filename = filename #print "filters ", (time.time()-starttime), "seconds" self.app.update() #print "load source ", (time.time()-starttime), "seconds" self.annotate_from_str(anns, filename, filter, filsyntax, syntax) self.app.update() #print "highlight anns ", (time.time()-starttime), "seconds" #print "highlight syntax ", (time.time()-starttime), "seconds" self.load_pref(filename + ".pref") self.clear_modified()
def save_ann(self): annotations = self.ann_to_string() filters = self.filter_to_string() try: self.app.logen.save_annotations(self.filename, annotations, filters) except PrologException,e: ## Error has occurred most probably parsing.... (Title, Msg) = e complain_loudly(master=self.app, title=Title,msg=Msg) return False
def save_ann(self): annotations = self.ann_to_string() filters = self.filter_to_string() try: self.app.logen.save_annotations(self.filename, annotations, filters) except PrologException, e: ## Error has occurred most probably parsing.... (Title, Msg) = e complain_loudly(master=self.app, title=Title, msg=Msg) return False
def load_source(self, filename,annfile=None,reset=False): if annfile is None: annfile = filename + ".ann" else: print "Loading different annfile %s" % annfile if not os.path.exists(annfile): print "Annotation file (%s) does not exist for %s" % (annfile,filename) if reset: self.app.logen.annotate_file(filename, mode='auto_bta') else: ans = ask_NoAnnfileDialog(master=self.app, Filename=filename) if ans == "simple": print "Simple BTA" if not self.app.logen.annotate_file(filename): complain_loudly(master=self.app, msg="Could not create annotation file!") elif ans == "reset": #self.app.reset_bta_file(self,filename=filename) #return self.app.logen.annotate_file(filename, mode='auto_bta') else: fd = open(filename + ".ann", "w") fd.write("% Empty annotation file") fd.close() starttime = time.time() (anns, syntax, filter, filsyntax) = self.app.logen.get_annotations(filename,annfile) print "Get annotations ", (time.time()-starttime), "seconds" #save anns for safety checks... self.anns = anns self.filename = filename #print "filters ", (time.time()-starttime), "seconds" self.app.update() #print "load source ", (time.time()-starttime), "seconds" self.annotate_from_str(anns,filename,filter,filsyntax,syntax) self.app.update() #print "highlight anns ", (time.time()-starttime), "seconds" #print "highlight syntax ", (time.time()-starttime), "seconds" self.load_pref(filename +".pref") self.clear_modified()