From f7cd4ab03a10bc0089840144e4fec98ec7981a10 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 9 May 2010 19:27:03 +0200 Subject: Improvements of HTML and text export. --- pyAggr3g470r.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 0daf89ca..726c2a1a 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -653,7 +653,7 @@ class Root: html += """

Notifications are sent to: %s

""" % \ (utils.mail_to, utils.mail_to) html += "\n
\n" + htmlfooter - return html + return html"

" + article[2].encode('utf-8') + "



" list_notification.exposed = True @@ -749,25 +749,30 @@ class Root: def export(self, export_method): """ - Export articles stored in the SQLite database in a text files. + Export articles stored in the SQLite database in text files. """ for rss_feed_id in self.feeds.keys(): folder = utils.path + "var/export/" + self.feeds[rss_feed_id][3] + folder = folder.replace(' ', '_') try: os.makedirs(folder) except OSError: - return self.error_page(folder+" already exists.") + return self.error_page(utils.path + "var/export/"+" already exists.\nYou should delete this folder.") for article in self.articles[rss_feed_id]: try: if export_method == "export_HTML": - f = open(folder + "/" + article[2]+ ".html", "w") + name = folder + "/" + article[1]+ ".html" + f = open(name.replace(' ', '_'), "w") content = htmlheader + content += "

" + article[2].encode('utf-8') + "


" content += article[4].encode('utf-8') content += "
\n" content += htmlfooter elif export_method == "export_TXT": - f = open(folder + "/" + article[2], "w") - content = utils.remove_html_tags(article[4].encode('utf-8')) + name = folder + "/" + article[1] + ".txt" + f = open(name.replace(' ', '_'), "w") + content = "Title: " + article[2].encode('utf-8') + "\n\n\n" + content += utils.remove_html_tags(article[4].encode('utf-8')) f.write(content) except IOError: pass -- cgit