]> git.phdru.name Git - bookmarks_db.git/blobdiff - bkmk-add.py
Minor refactoring
[bookmarks_db.git] / bkmk-add.py
index 7e7b415b469ddef45775fdcf0fb0f0a011b1ae5f..b882cf9082e22e7b0a807e0bba81c8b4f9decc3c 100755 (executable)
@@ -1,14 +1,17 @@
 #! /usr/bin/env python
-"""
-   Add a bookmark to the database.
+"""Add a bookmark to the database
+
+This file is a part of Bookmarks database and Internet robot.
 
-   Written by Broytman. Copyright (C) 2002-2007 PhiloSoft Design.
 """
 
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2002-2014 PhiloSoft Design"
+__license__ = "GNU GPL"
 
 import sys, os, time
 from bkmk_objects import Bookmark
-from Robots.bkmk_rsimple import robot_simple
+from robots import robot
 
 
 def run():
@@ -33,7 +36,7 @@ def run():
       sys.stderr.write("Usage: bkmk-add [-s] [-t title] url\n")
       sys.exit(1)
 
-   from storage import storage, import_storage
+   from storage import storage
    storage = storage()
 
    if report_stats:
@@ -49,8 +52,10 @@ def run():
    now = int(time.time())
    bookmark = Bookmark(href, str(now), '0', '0')
    bookmark.name = ''
+   bookmark.parent = None
 
-   robot = robot_simple(None)
+   global robot
+   robot = robot(None)
 
    if robot.check_url(bookmark): # get real title and last modified date
       if title: # forced title
@@ -59,6 +64,7 @@ def run():
          bookmark.name = bookmark.real_title
       if report_stats:
          sys.stdout.write("Adding %s with title '%s'\n" % (href, bookmark.name))
+      del bookmark.parent
       root_folder.append(bookmark)
 
       if report_stats: