import pickle
from subproc import Subprocess, RecordFile
-from bkmk_objects import Robot
+from bkmk_objects import Robot, copy_bkmk
# This is to catch 'close failed: [Errno 9] Bad file descriptor' message
if check_subp.waitForPendingChar(60): # wait a minute
new_b = pickle.loads(subp_pipe.read_record())
- for attr in (
- "error", "no_error",
- "moved", "size", "md5", "real_title",
- "last_tested", "last_modified", "test_time",
- "icon", "icon_href", "charset",
- ):
- if hasattr(new_b, attr):
- setattr(bookmark, attr, getattr(new_b, attr))
+ copy_bkmk(new_b, bookmark)
else:
bookmark.error = "Subprocess connection timed out"
restart_subp(self.log)
import time
-from bkmk_objects import Writer
+from bkmk_objects import Writer, bkmk_attrs
from compat import unicode
b.keyword, b.comment)
)
- for attr_name, attr_out in (
- ("error", "Error"), ("no_error", "NoError"),
- ("moved", "Moved"), ("size", "Size"), ("md5", "Md5"),
- ("real_title", "RealTitle"), ("test_time", "TestTime"),
- ("icon_href", "IconURI"), ("icon", "Icon"), ("charset", "Charset"),
- ):
+ for attr_name, attr_out in bkmk_attrs.items():
if hasattr(b, attr_name):
value = getattr(b, attr_name)
#if isinstance(value, unicode):
self.charset = charset
+bkmk_attrs = {
+ "charset": "Charset",
+ "error": "Error",
+ "icon": "Icon",
+ "icon_href": "IconURI",
+ "md5": "Md5",
+ "moved": "Moved",
+ "no_error": "NoError",
+ "real_title": "RealTitle",
+ "size": "Size",
+ "test_time": "TestTime",
+}
+
+
+bkmk_attrs_sentinel = object()
+
+
+def copy_bkmk(old_bkmk, new_bkmk):
+ for attr in bkmk_attrs.keys():
+ value = getattr(old_bkmk, attr, bkmk_attrs_sentinel)
+ if value is not bkmk_attrs_sentinel:
+ setattr(new_bkmk, attr, value)
+
+
class Ruler(object):
isFolder = 0
isBookmark = 0
__license__ = "GNU GPL"
+from bkmk_objects import copy_bkmk
+
+
def run():
from getopt import getopt
optlist, args = getopt(sys.argv[1:], "ise")
if href in checked:
log("Already checked %s" % href)
old_object = root_folder.linear[checked[href]]
- for attr_name in (
- "last_visit", "last_modified",
- "error", "no_error", "moved", "size", "md5", "real_title",
- "last_tested", "test_time", "icon", "charset",
- ):
- if hasattr(old_object, attr_name):
- setattr(object, attr_name,
- getattr(old_object, attr_name))
+ copy_bkmk(old_object, object)
else:
log("Checking %s" % href)
robot.check_bookmark(object)