X-Git-Url: https://git.phdru.name/?p=bookmarks_db.git;a=blobdiff_plain;f=bkmk-add.py;h=b882cf9082e22e7b0a807e0bba81c8b4f9decc3c;hp=24952ce0d74423c93010d3a075d9d8f603c94053;hb=96e39d55c791326368ff14d538850e14ba5a2c97;hpb=9edef5a570ea28f7c06d8d92fdd70afe0ea86809 diff --git a/bkmk-add.py b/bkmk-add.py index 24952ce..b882cf9 100755 --- a/bkmk-add.py +++ b/bkmk-add.py @@ -1,17 +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 BroytMann, Aug 2002. Copyright (C) 2002 PhiloSoft Design """ +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2002-2014 PhiloSoft Design" +__license__ = "GNU GPL" -import sys, os, time, urllib +import sys, os, time from bkmk_objects import Bookmark -from Robots.bkmk_rsimple import robot_simple - -import tempfile -tempfname = "bkmk-add" + tempfile.gettempprefix() + "tmp" +from robots import robot def run(): @@ -36,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: @@ -52,17 +52,19 @@ def run(): now = int(time.time()) bookmark = Bookmark(href, str(now), '0', '0') bookmark.name = '' + bookmark.parent = None - robot = robot_simple(tempfname, None) - url_type, url_rest = urllib.splittype(href) + global robot + robot = robot(None) - if robot.check_url(bookmark, url_type, url_rest): # get real title and last modified date + if robot.check_url(bookmark): # get real title and last modified date if title: # forced title bookmark.name = title elif hasattr(bookmark, "real_title"): 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: @@ -75,11 +77,5 @@ def run(): print "Ok" - try: - os.unlink(tempfname) - except os.error: - pass - - if __name__ == '__main__': run()