Update index print, PEP 8 fixes.

This commit is contained in:
Arun Prakash Jana 2016-10-12 00:19:05 +05:30
parent 3b80984afc
commit 6104873401
No known key found for this signature in database
GPG Key ID: A75979F35C080412

24
buku
View File

@ -954,7 +954,8 @@ class BukuDb:
''' '''
if index == 0: if index == 0:
self.cur.execute('SELECT id from bookmarks ORDER BY RANDOM() LIMIT 1') query = 'SELECT id from bookmarks ORDER BY RANDOM() LIMIT 1'
self.cur.execute(query)
result = self.cur.fetchone() result = self.cur.fetchone()
# Return if no entries in DB # Return if no entries in DB
@ -1422,32 +1423,31 @@ def prompt(results, noninteractive=False, delete=False):
break break
def print_record(row, count=0): def print_record(row, idx=0):
'''Print a single DB record '''Print a single DB record
Handles differently for search and print (count = 0) Handles differently for search and print (idx = 0)
''' '''
# Print index and URL # Print index and URL
if count != 0: if idx != 0:
printstr = '\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m \ pr = "\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m \
\x1B[1m[%s]\x1B[0m\n' % (count, row[1], row[0]) \x1B[1m[%s]\x1B[0m\n" % (idx, row[1], row[0])
else: else:
printstr = '\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m\n' \ pr = '\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m\n' % (row[0], row[1])
% (row[0], row[1])
# Print title # Print title
if row[2] != '': if row[2] != '':
printstr = '%s \x1B[91m>\x1B[0m %s\n' % (printstr, row[2]) pr = '%s \x1B[91m>\x1B[0m %s\n' % (pr, row[2])
# Print description # Print description
if row[4] != '': if row[4] != '':
printstr = '%s \x1B[91m+\x1B[0m %s\n' % (printstr, row[4]) pr = '%s \x1B[91m+\x1B[0m %s\n' % (pr, row[4])
# Print tags IF not default (DELIMITER) # Print tags IF not default (DELIMITER)
if row[3] != DELIMITER: if row[3] != DELIMITER:
printstr = '%s \x1B[91m#\x1B[0m %s\n' % (printstr, row[3][1:-1]) pr = '%s \x1B[91m#\x1B[0m %s\n' % (pr, row[3][1:-1])
print(printstr) print(pr)
def format_json(resultset, single=False, showOpt=0): def format_json(resultset, single=False, showOpt=0):