X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Writers%2Fbkmk_whtml.py;h=ad109f82686ac70c16e514212cbc5f278659efa8;hb=01e7f1237af1fa33a1feb0d07d5bb2e5e438962e;hp=775d336fea0c4060a35090c307f8be12cfe20311;hpb=d90638aca4f4313717261478e1d8349ccb97afc5;p=bookmarks_db.git diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index 775d336..ad109f8 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -1,29 +1,31 @@ -""" - Convert a bkmk database back to bookmarks.html +"""Convert a bkmk database back to bookmarks.html - Written by BroytMann. Copyright (C) 2000-2007 PhiloSoft Design +This file is a part of Bookmarks database and Internet robot. """ +__version__ = "$Revision$"[11:-2] +__revision__ = "$Id$"[5:-2] +__date__ = "$Date$"[7:-2] +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" +__license__ = "GNU GPL" + +__all__ = ['writer_html'] -import os -MZFORMAT = os.environ.has_key("BKMK_MZFORMAT") -if MZFORMAT: - NSFORMAT = False -else: - NSFORMAT = os.environ.has_key("BKMK_NSFORMAT") + +from m_lib.defenc import default_encoding +from bkmk_objects import Writer, BKMK_FORMAT, quote_title def dump_comment(comment): comment = comment.replace("
\n", "\n") - if NSFORMAT: + if BKMK_FORMAT == "NETSCAPE": comment = comment.replace("\n", "
\n") return comment ind_s = " "*4 -from bkmk_objects import Writer - class writer_html(Writer): filename = "bookmarks.html" @@ -34,25 +36,28 @@ class writer_html(Writer): def root_folder(self, f): self.outfile.write("\n") self.outfile.write(f.header + "\n") - self.outfile.write('

%s

\n\n' % f.name) + self.outfile.write('

%s

\n\n' % quote_title(f.name)) self._folder(f, 0) def start_folder(self, f, level): self.outfile.write(ind_s*level + '

%s

\n' % f.name) + if (BKMK_FORMAT == "MOZILLA") and f.last_modified: self.outfile.write(' LAST_MODIFIED="%s"' % f.last_modified) + self.outfile.write('>%s\n' % quote_title(f.name)) self._folder(f, level) def end_folder(self, f, level): self.outfile.write(ind_s*level + "

\n") def bookmark(self, b, level): - self.outfile.write(ind_s*(level+1) + '

%s\n' % b.name) + self.outfile.write('>%s\n' % quote_title(b.name)) if b.comment: self.outfile.write('
%s\n' % dump_comment(b.comment)) def ruler(self, r, level):