def __init__ (self, url, data, content_type): self.ignore_unparsed = False self.url = url #self.name = 'Web Parser' self.soup = BeautifulSoup.BeautifulSoup(data, convertEntities=BeautifulSoup.BeautifulStoneSoup.XHTML_ENTITIES, ) InteractiveImporter.__init__(self) #self.generic_parser = RecipeParser() self.preparse() self.get_images() self.text_parser = RecipeParser()
def __init__(self, url, data, content_type): self.ignore_unparsed = False self.url = url #self.name = 'Web Parser' self.soup = BeautifulSoup.BeautifulSoup( data, convertEntities=BeautifulSoup.BeautifulStoneSoup.XHTML_ENTITIES, ) InteractiveImporter.__init__(self) #self.generic_parser = RecipeParser() self.preparse() self.get_images() self.text_parser = RecipeParser()
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 __init__(self, filename): self.filename = filename InteractiveImporter.__init__(self)
def do_run(self): parsed = self.parse_webpage() self.set_parsed(parsed) return InteractiveImporter.do_run(self)
def do_run (self): parsed = self.parse_webpage() self.set_parsed(parsed) return InteractiveImporter.do_run(self)
def __init__ (self, filename): self.filename = filename InteractiveImporter.__init__(self)