Modify API name.
Signed-off-by: Arun Prakash Jana <engineerarun@gmail.com>
This commit is contained in:
parent
c11e419082
commit
586992a5ac
24
buku
24
buku
@ -364,6 +364,18 @@ class BukuDb:
|
||||
|
||||
return (conn, cur)
|
||||
|
||||
def get_bookmark_by_index(self, index):
|
||||
"""Get a bookmark from database by its ID.
|
||||
Return data as a tuple. Return None if index not found.
|
||||
"""
|
||||
|
||||
self.cur.execute('SELECT * FROM bookmarks WHERE id = ?', (index,))
|
||||
results = self.cur.fetchall()
|
||||
if len(results) == 0:
|
||||
return None
|
||||
else:
|
||||
return results[0]
|
||||
|
||||
def get_bookmark_index(self, url):
|
||||
"""Check if URL already exists in DB
|
||||
|
||||
@ -643,18 +655,6 @@ class BukuDb:
|
||||
except IndexError:
|
||||
print('Index out of bound')
|
||||
|
||||
def get_bookmark_by_id(self, index):
|
||||
"""Get a bookmark from database by its ID.
|
||||
Return data as a tuple. Return None if index not found.
|
||||
"""
|
||||
|
||||
self.cur.execute('SELECT * FROM bookmarks WHERE id = ?', (index,))
|
||||
results = self.cur.fetchall()
|
||||
if len(results) == 0:
|
||||
return None
|
||||
else:
|
||||
return results[0]
|
||||
|
||||
def print_bookmark(self, index, empty=False):
|
||||
"""Print bookmark details at index or all bookmarks if index is None
|
||||
Print only bookmarks with blank title or tag if empty is True
|
||||
|
@ -98,7 +98,7 @@ class TestBukuDb(unittest.TestCase):
|
||||
index = bdb.get_bookmark_index(bookmark[0])
|
||||
self.assertEqual(idx + 1, index)
|
||||
# retrieving bookmark from database
|
||||
from_db = bdb.get_bookmark_by_id(index)
|
||||
from_db = bdb.get_bookmark_by_index(index)
|
||||
self.assertIsNotNone(from_db)
|
||||
# comparing data
|
||||
for pair in zip(from_db[1:], bookmark):
|
||||
|
Loading…
x
Reference in New Issue
Block a user