__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['robot_forking']
+
+
+import sys, os
+
try:
- import cPickle
- pickle = cPickle
+ import cPickle as pickle
except ImportError:
import pickle
-import sys, os
from subproc import Subprocess, RecordFile
+from bkmk_objects import Robot
+
# This is to catch 'close failed: [Errno 9] Bad file descriptor' message
# from os.close() in Subprocess.die() and errors from from the subprocess.
subp_pipe = RecordFile(check_subp)
-from bkmk_objects import Robot
-
class robot_forking(Robot):
def check_url(self, bookmark):
if not check_subp:
# Tested
return 1
-
def stop(self):
stop_subp(None) # Stop subprocess; do not log restarting
__copyright__ = "Copyright (C) 1999-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = []
+
+
import sys, os
lib_dir = os.path.normpath(os.path.dirname(sys.argv[0]) + os.sep + os.pardir)
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['robot_simple', 'get_error']
+
+
import sys, os
import time, urllib
from base64 import b64encode
# Tested
return 1
-
def finish_check_url(self, bookmark, fname=None):
# Calculate these attributes even in case of an error
if fname and os.path.exists(fname):
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['robot_simple_tos']
+
+
import socket
socket.setdefaulttimeout(900)
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['storage_flad']
+
+
import string
from m_lib.flad import fladm
from bkmk_objects import Folder, Bookmark, Ruler, Walker
b.keyword, b.comment.replace('\n', "\\n"),
b.icon_href or '', b.icon or '', b.charset or ''))
-
def ruler(self, r, level):
self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))
-
def store(self, root_folder):
self.outfile = open(self.filename, 'w')
root_folder.walk_depth(self)
self.outfile.close()
-
def unindent(self, old_level, new_level):
while old_level > new_level:
old_level = old_level - 1
__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['storage_json']
+
+
try:
import json
except ImportError:
outfile.close()
del self.dict
-
def load(self):
infile = open(self.filename, 'rb')
bkmk_s = infile.read()
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['storage_pickle']
+
+
try:
import cPickle
pickle = cPickle
class storage_pickle:
filename = "bookmarks_db.pickle"
-
def store(self, root_folder):
outfile = open(self.filename, 'wb')
pickle.dump(root_folder, outfile, 1)
outfile.close()
-
def load(self):
infile = open(self.filename, 'rb')
root_folder = pickle.load(infile)
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['writer_flad']
+
+
import time
from bkmk_objects import Writer
Writer.__init__(self, outfile, prune)
self.first_object = 1
-
def start_folder(self, f, level):
self.outfile.write("""
Level: %d
LastModified: %s
""" % (level, f.name, strftime(f.add_date), f.comment, f.last_modified or ''))
-
def bookmark(self, b, level):
self.outfile.write("""
Level: %d
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['writer_flad_err']
+
+
import time
from bkmk_wflad import writer_flad
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['writer_html']
+
+
from bkmk_objects import Writer, BKMK_FORMAT, quote_title
__copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design"
__license__ = "GNU GPL"
-ind_s = " "*4
+__all__ = ['writer_txt']
from bkmk_objects import Writer
+ind_s = " "*4
+
+
class writer_txt(Writer):
filename = "dump.txt"
__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, cgi
BKMK_FORMAT = os.environ.get("BKMK_FORMAT", "MOZILLA")
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['BkmkParser']
+
+
import sys, os
from m_lib.net.www.html import HTMLParser
from bkmk_objects import Folder, Bookmark, Ruler
self.charset = ""
self.recode = None
-
def handle_data(self, data):
if data:
if DEFAULT_CHARSET:
data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "xmlcharrefreplace")
self.accumulator += data
-
# Mozilla - get charset
def do_meta(self, attrs):
http_equiv = ""
else:
DEFAULT_CHARSET = locale.getpreferredencoding()
-
def start_title(self, attrs):
if DEFAULT_CHARSET:
self.accumulator += '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%s">\n' % DEFAULT_CHARSET
def end_title(self):
self.accumulator += "</TITLE>"
-
# Start root folder
def start_h1(self, attrs):
root_folder = Folder()
debug("Root folder name: `%s'" % accumulator)
self.root_folder.name = accumulator
-
# Start a folder
def start_h3(self, attrs):
last_modified = None
debug("Folder name: `%s'" % accumulator)
self.current_folder.name = accumulator
-
# Start a bookmark
def start_a(self, attrs):
add_date = None
bookmark = self.current_folder[-1]
bookmark.name = accumulator
-
def flush(self):
accumulator = self.accumulator
current_object.comment += accumulator.strip()
debug("Comment: `%s'" % current_object.comment)
-
def start_dl(self, attrs):
self.flush()
do_dt = start_dl
-
# End of folder
def end_dl(self):
self.flush()
debug("FOLDER STACK is EMPTY!!! (2)")
self.current_object = None
-
def close(self):
HTMLParser.close(self)
if self.folder_stack:
raise ValueError, "wrong folder stack: %s" % self.folder_stack
-
def do_dd(self, attrs):
pass
do_p = do_dd
-
# Start ruler
def do_hr(self, attrs):
self.flush()
self.current_object = None
self.objects += 1
-
# BR in comment
def do_br(self, attrs):
self.accumulator += "<BR>"
-
# Allow < in the text
def unknown_starttag(self, tag, attrs):
self.accumulator += "<%s>" % tag
-
# Do not allow unknow end tags
def unknown_endtag(self, tag):
raise NotImplementedError("Unknow end tag `%s'" % tag)
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
import codecs
universal_charset = "utf-8"
__copyright__ = "Copyright (C) 2007-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
import re
from sgmllib import SGMLParser, SGMLParseError
from BeautifulSoup import BeautifulSoup, CData
__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
from elementtidy import TidyHTMLTreeBuilder
from .util import HTMLParser
__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
from html5lib import HTMLParser as HTML5Parser
from .util import HTMLParser
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
from HTMLParser import HTMLParseError
from m_lib.net.www.html import HTMLParser as _HTMLParser
def end_head(self):
raise HTMLHeadDone()
-
def do_meta(self, attrs):
http_equiv = ""
content = ""
if http_equiv == "refresh":
self.refresh = content
-
def start_title(self, attrs):
self.accumulator = ''
if not self.title: # use only the first title
self.title = self.accumulator
-
def do_link(self, attrs):
has_icon = False
href = None
__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['parse_html']
+
+
from lxml.html import parse
from .util import HTMLParser
__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['HTMLParser']
+
+
from HTMLParser import HTMLParser
class HTMLParser(HTMLParser):
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['import_robot', 'robot']
+
+
from os import environ
robot_name = environ.get("BKMK_ROBOT", "forking")
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['import_storage', 'storage']
+
+
from os import environ
storage_name = environ.get("BKMK_STORAGE", "pickle")
__copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
__license__ = "GNU GPL"
+__all__ = ['import_writer', 'writer']
+
+
from os import environ
writer_name = environ.get("BKMK_WRITER", "html")