__all__ = ['Folder', 'Bookmark', 'Ruler', 'Walker', 'Writer', 'Robot',
'InverseLinker', 'Linear', 'make_linear', 'make_tree', 'break_tree',
- 'quote_title', 'unquote_title',
+ 'quote_title', 'unquote_title', 'parse_params', 'set_params',
]
title = HTMLParser().unescape(title.replace("&", '&').decode('utf-8'))
title = title.encode('utf-8').replace("'", "'")
return title
+
+
+def parse_params(param_str):
+ params = param_str.split(':')
+ main_param = params.pop(0)
+ param_list = {}
+ for param in params:
+ key, value = param.split('=', 1)
+ param_list[key] = value
+ return main_param, param_list
+
+def set_params(obj, params):
+ if hasattr(params, "items"):
+ params = params.items()
+ for key, value in params:
+ setattr(obj, key, value)
Adapt JSON storage to recent Mozilla export format.
+ Add ChangeLog.
+
+ Allow parameters in BKMK_* environment variables; for example,
+ BKMK_ROBOT=forking:subproc=urllib or
+ BKMK_STORAGE=json:filename=bookmarks_db.json.
+
WHERE TO GET
Home page: http://phdru.name/Software/Python/#bookmarks_db
git clone http://git.phdru.name/bookmarks_db.git
git clone git://git.phdru.name/bookmarks_db.git
+ Requires: Python 2.5+, m_lib 2.0+.
+
AUTHOR
Oleg Broytman <phd@phdru.name>
Add ChangeLog.
+ Allow parameters in BKMK_* environment variables; for example,
+ BKMK_ROBOT=forking:subproc=urllib or
+ BKMK_STORAGE=json:filename=bookmarks_db.json.
+
WHAT'S NEW in version 4.5.6 (2014-01-14)
-Allow parameters in BKMK_ROBOT; for example, 'forking:urllib'.
-
A new robot based on urllib2.
A new robot based on PycURL.
"""Thin wrapper for module Robots. Provides "default" robot
This file is a part of Bookmarks database and Internet robot.
+
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 1997-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 1997-2014 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['import_robot', 'robot']
from os import environ
-robot_name = environ.get("BKMK_ROBOT", "forking")
+from bkmk_objects import parse_params, set_params
+
+robot_name, robot_params = parse_params(environ.get("BKMK_ROBOT", "forking"))
def import_robot(robot_name):
exec "from Robots import bkmk_r%s" % robot_name
return robot
robot = import_robot(robot_name)
+set_params(robot, robot_params)
"""Thin wrapper for module Storage. Provides "default" storage
This file is a part of Bookmarks database and Internet robot.
+
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 1997-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 1997-2014 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['import_storage', 'storage']
from os import environ
-storage_name = environ.get("BKMK_STORAGE", "pickle")
+from bkmk_objects import parse_params, set_params
+
+storage_name, storage_params = parse_params(environ.get("BKMK_STORAGE", "pickle"))
def import_storage(storage_name):
exec "from Storage import bkmk_st%s" % storage_name
return storage
storage = import_storage(storage_name)
+set_params(storage, storage_params)
"""Thin wrapper for module Writers. Provides "default" writer
This file is a part of Bookmarks database and Internet robot.
+
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 1997-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 1997-2014 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['import_writer', 'writer']
from os import environ
-writer_name = environ.get("BKMK_WRITER", "html")
+from bkmk_objects import parse_params, set_params
+
+writer_name, writer_params = parse_params(environ.get("BKMK_WRITER", "html"))
def import_writer(writer_name):
exec "from Writers import bkmk_w%s" % writer_name
return writer
writer = import_writer(writer_name)
+set_params(writer, writer_params)