diff --git a/buku b/buku index 01c542d..ebe912c 100755 --- a/buku +++ b/buku @@ -51,16 +51,15 @@ except ImportError: # Globals addindex = None # DB index to insert URL into -openurl = None # Open URL in browser showindex = None # Index of bookmark to show showOpt = 0 # Modify show. 1: show only URL, 2: show URL and tag entry = None # DB index to update or delete update = False # Update a bookmark in DB -debug = False # Enable debug logs titleData = None # Title fetched from a page titleManual = None # Manually add a title offline iterations = 8 # Number of hash iterations to generate key jsonOutput = False # Output json formatted result +debug = False # Enable debug logs pipeargs = [] # Holds arguments piped to the program _VERSION_ = 1.9 # Program version @@ -597,7 +596,8 @@ def cleardb(conn, cur, index): def printdb(cur, index, empty=False): """Print bookmark details at index or all bookmarks if index is None - Print only bookmarks with empty title or tags if empty is True + Print only bookmarks with blank title or tags if empty is True + Note: URL is printed on top because title may be blank Params: cursor, index to print, flag to show only bookmarks with no title or tags """ @@ -748,7 +748,7 @@ def fetchopen(index): """ try: - for row in cur.execute("SELECT URL FROM bookmarks WHERE id = ?", (int(index),)): + for row in cur.execute("SELECT URL FROM bookmarks WHERE id = ?", (index,)): url = unquote(row[0]) browser_open(url) return @@ -927,6 +927,7 @@ def decrypt_file(): if dbhash != enchash: os.remove(dbpath) print("Decryption failed"); + sys.exit(1) else: os.remove(encpath) print("File decrypted") @@ -1049,13 +1050,13 @@ addarg('-k', '--decrypt', dest='decrypt', action='store_true', help='decrypt (unlock) database file') addarg('-l', '--encrypt', dest='encrypt', action='store_true', # DONE help='encrypt (lock) database file') -addarg('-o', '--open', dest='openurl', type=int, metavar='N', +addarg('-o', '--open', dest='openurl', type=int, metavar='N', # DONE help='open URL at DB index N in browser') addarg('-p', '--print', dest='showindex', type=int, metavar='N', help='show details of bookmark record at DB index N, N=0 shows all') -addarg('-r', '--replace', nargs=2, dest='replace', metavar=('oldtag', 'newtag'), +addarg('-r', '--replace', nargs=2, dest='replace', metavar=('oldtag', 'newtag'), # DONE help='replace oldtag with newtag, delete oldtag if newtag=none') -addarg('-t', '--iterate', dest='iterations', type=int, metavar='N', +addarg('-t', '--iterate', dest='iterations', type=int, metavar='N', # DONE help='use N (> 0) hash iterations to generate key, for -k, -l') addarg('-x', '--format', dest='showOpt', metavar='N', help='modify -p behaviour, N=1: show only URL, N=2: show URL and tag') @@ -1188,6 +1189,8 @@ except GetoptError as e: args = argparser.parse_args() titleManual = args.titleManual +if args.iterations is not None: + iterations = args.iterations jsonOutput = args.jsonOutput debug = args.debug keywords = [] @@ -1212,7 +1215,7 @@ if args.decrypt == True: sys.exit(1) decrypt_file() -# Initilize the database and get handles +# Initialize the database and get handles conn, cur = initdb() # Add a record @@ -1256,8 +1259,8 @@ if args.empty == True: printdb(cur, 0, True) # Open URL in browser -if openurl != None: - fetchopen(openurl) +if args.openurl is not None: + fetchopen(args.openurl) # Close the connection before exiting conn.close()