X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=bkmk-add.py;h=f0db4eaf7e0b3d7f592c4db24a7aca16dceba828;hb=c1c90856aeffcf8f2bcb7abf39934d5e0f8be36d;hp=46efe3e870ec0c33a395a73067a69b96478c96ea;hpb=0e76f1851882b99da63a7c8a9e4cdf0c4a48657f;p=bookmarks_db.git diff --git a/bkmk-add.py b/bkmk-add.py index 46efe3e..f0db4ea 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 Broytman. Copyright (C) 2002-2007 PhiloSoft Design. """ +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2002-2017 PhiloSoft Design" +__license__ = "GNU GPL" 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: @@ -46,14 +46,16 @@ def run(): root_folder = storage.load() if report_stats: - print "Ok" + print("Ok") href = args[0] now = int(time.time()) bookmark = Bookmark(href, str(now), '0', '0') bookmark.name = '' + bookmark.parent = None - robot = robot_simple(tempfname, None) + global robot + robot = robot(None) if robot.check_url(bookmark): # get real title and last modified date if title: # forced title @@ -62,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: @@ -71,13 +74,7 @@ def run(): storage.store(root_folder) if report_stats: - print "Ok" - - - try: - os.unlink(tempfname) - except os.error: - pass + print("Ok") if __name__ == '__main__':