def do_run (self): if os.path.getsize(self.filename) > MAX_PLAINTEXT_LENGTH*16: del data import gourmet.gtk_extras.dialog_extras as de de.show_message(title=_('Big File'), label=_('File %s is too big to import'%self.filename), sublabel=_('Your file exceeds the maximum length of %s characters. You probably didn\'t mean to import it anyway. If you really do want to import this file, use a text editor to split it into smaller files and try importing again.')%MAX_PLAINTEXT_LENGTH, message_type=Gtk.MessageType.ERROR) return with open(self.filename, 'rb') as ifi: data = '\n'.join(check_encodings.get_file(ifi)) self.set_text(data) return InteractiveImporter.do_run(self)
def do_run (self): if os.path.getsize(self.filename) > MAX_PLAINTEXT_LENGTH*16: del data ifi.close() import gourmet.gtk_extras.dialog_extras as de de.show_message(title=_('Big File'), label=_('File %s is too big to import'%self.filename), sublabel=_('Your file exceeds the maximum length of %s characters. You probably didn\'t mean to import it anyway. If you really do want to import this file, use a text editor to split it into smaller files and try importing again.')%MAX_PLAINTEXT_LENGTH, message_type=gtk.MESSAGE_ERROR) return ifi = file(self.filename,'r') data = '\n'.join(check_encodings.get_file(ifi)) ifi.close() self.set_text(data) return InteractiveImporter.do_run(self)
def pre_run (self): self.lines = check_encodings.get_file(self.fn) self.total_lines = len(self.lines) print 'we have ',self.total_lines,'lines in file',self.fn