X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=bkmk_objects.py;h=281b95c0f57747f0a728b27046b587bd49556c89;hb=640a29c4011d07346413cf75f758e3d721d36d74;hp=a9567e22134fd70b9adcefe788c2b2bb3a45746f;hpb=d9f2f4316537aea2cf87b2f77bf7d78eb54978a4;p=bookmarks_db.git diff --git a/bkmk_objects.py b/bkmk_objects.py index a9567e2..281b95c 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -1,12 +1,24 @@ -""" - Objects to represent bookmarks.html structure +"""Objects to represent bookmarks.html structure - Written by Oleg Broytman. Copyright (C) 2000-2010 PhiloSoft Design. +This file is a part of Bookmarks database and Internet robot. """ -import os, cgi -BKMK_FORMAT = os.environ.get("BKMK_FORMAT", "MOZILLA") +__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__ = ['Folder', 'Bookmark', 'Ruler', 'Walker', 'Writer', 'Robot', + 'InverseLinker', 'Linear', 'make_linear', 'make_tree', 'break_tree', + 'quote_title', 'unquote_title', +] + +import os, urllib + +BKMK_FORMAT = os.environ.get("BKMK_FORMAT", "MOZILLA") class Folder(list): isFolder = 1 @@ -44,7 +56,31 @@ class Bookmark: isBookmark = 1 def __init__(self, href, add_date, last_visit=None, last_modified=None, - keyword=None, comment='', icon_href=None, icon=None, charset=None): + keyword=None, comment='', icon_href=None, icon=None, + charset=None, parser_charset=None): + protocol, request = urllib.splittype(href) + user, password, port = None, None, None + host, path = urllib.splithost(request) + if host: + user, host = urllib.splituser(host) + if user: + user, password = urllib.splitpasswd(user) + host, port = urllib.splitport(host) + if port: port = int(port) + + href = protocol + "://" + if user: + href += urllib.quote(user) + if password: + href += ':' + urllib.quote(password) + href += '@' + if host: + href += host.decode(parser_charset or 'utf-8').encode('idna') + if port: + href += ':%d' % port + if path: + href += path + self.href = href self.add_date = add_date self.last_visit = last_visit @@ -99,8 +135,7 @@ class Writer(Walker): class Robot: - def __init__(self, tempfname, log): - self.tempfname = tempfname + def __init__(self, log): self.log = log def stop(self):