Remove insert bookmark operation.

This commit is contained in:
Arun Prakash Jana 2016-05-23 00:50:50 +05:30
parent c68ddf6ebd
commit 53da73b8db
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB

47
buku
View File

@ -202,11 +202,10 @@ class BukuDb:
return resultset[0][0]
def add_bookmark(self, keywords, insertindex=0):
"""Add a new bookmark or insert a
new record at insertindex (if empty)
def add_bookmark(self, keywords):
"""Add a new bookmark
Params: keywords, index to update, index to insert at
Params: keywords (url + optional tags)
"""
global tagManual
@ -244,21 +243,12 @@ class BukuDb:
description = ''
try:
if insertindex == 0: # insertindex is index number to insert record at
self.cur.execute('INSERT INTO bookmarks(URL, metadata, tags, desc) VALUES (?, ?, ?, ?)', (url, meta, tags, description))
else:
self.cur.execute('INSERT INTO bookmarks(id, URL, metadata, tags, desc) VALUES (?, ?, ?, ?, ?)', (insertindex, url, meta, tags, description))
self.cur.execute('INSERT INTO bookmarks(URL, metadata, tags, desc) VALUES (?, ?, ?, ?)', (url, meta, tags, description))
self.conn.commit()
print("Added at index %d\n" % self.cur.lastrowid)
self.printdb(self.cur.lastrowid)
except sqlite3.IntegrityError:
for row in self.cur.execute("SELECT id from bookmarks where URL LIKE ?", (url,)):
print("URL already exists at index %s" % row[0])
return
# Print error for index existing case
print("Index %d exists" % insertindex)
except Exception as e:
print("\x1b[1mEXCEPTION\x1b[21m [add_bookmark]: (%s) %s" % (type(e).__name__, e))
def update_bookmark(self, index, url='', tag_manual=None, title_manual=None, desc=None):
@ -1336,13 +1326,6 @@ power_group.add_argument('-j', '--json', dest='jsonOutput', action='store_true',
power_group.add_argument('-o', '--open', dest='openurl', type=int, metavar='N', help=argparse.SUPPRESS)
power_group.add_argument('-z', '--debug', dest='debug', action='store_true', help=argparse.SUPPRESS)
"""
# NOTE: Insert is functional but commented because DB compaction serves the purpose.
addarg = argparser.add_argument
addarg('-i', '--insert', nargs='+', dest='insert', metavar=('N', 'URL tags'),
help=" insert new bookmark with URL and tags at free DB index N; frees index if URL and tags are omitted")
"""
# Show help and exit if no arguments
if len(sys.argv) < 2:
argparser.print_help(sys.stderr)
@ -1466,21 +1449,5 @@ if args.openurl is not None:
bdb.close_quit(1)
bdb.browse_by_index(args.openurl)
"""
# NOTE: Insert is functional but commented because DB compaction serves the purpose.
# Insert a record at an index
if args.insert is not None:
if not args.insert[0].isdigit():
printmsg("Index must be a number >= 1", "ERROR")
close_quit(conn, 1)
insertindex = int(args.insert[0])
if insertindex < 1:
printmsg("Index must be a number >= 1", "ERROR")
close_quit(conn, 1)
if len(args.insert) == 1:
pass # No operation
else:
add_bookmark(conn, cur, args.insert[1:], insertindex)
"""
# Close DB connection and quit
bdb.close_quit(0)