View Single Post
Old 02-13-2011, 06:25 AM   #3
tobias2
Member
tobias2 began at the beginning.
 
Posts: 18
Karma: 36
Join Date: Feb 2011
Device: Kindle
I am not too familiar with Python programming. Is there a simple call that I can add in build_index such that anything that is defined in preprocess_regexps gets processed? Right now the code (in the "Now Toronto" example) is as follows:

Code:
    preprocess_regexps    = [
        (re.compile(r'foo'), lambda match: 'bar'),
    ]

    def build_index(self):
        epub_feed = "http://feeds.feedburner.com/NowEpubEditions"
        soup = self.index_to_soup(epub_feed)
        url = soup.find(name = 'feedburner:origlink').string
        f = urllib2.urlopen(url)
        tmp = PersistentTemporaryFile(suffix='.epub')
        self.report_progress(0,_('downloading epub'))
        tmp.write(f.read())
        tmp.close()
        zfile = zipfile.ZipFile(tmp.name, 'r')
        self.report_progress(0,_('extracting epub'))
        zfile.extractall(self.output_dir)
        tmp.close()
        index = os.path.join(self.output_dir, 'content.opf')
        self.report_progress(1,_('epub downloaded and extracted'))

        return index
Thanks,

Tobias
tobias2 is offline   Reply With Quote