diff --git a/buku.1 b/buku.1 index 91fe782..672ea89 100644 --- a/buku.1 +++ b/buku.1 @@ -77,6 +77,7 @@ Bookmarks with immutable titles are listed with '(L)' after the title. - Auto-import looks in the default installation path and default user profile. - URLs starting with `place:`, `file://` and `apt:` are ignored during import. - Folder names are automatically imported as tags if --tacit is used. + - An auto-generated tag in the format 'YYYYMonDD' is added if --tacit is not used. .PP .IP 10. 4 \fBEncryption\fR is optional and manual. AES256 algorithm is used. To use encryption, the database file should be unlocked (-k) before using \fBbuku\fR and locked (-l) afterwards. Between these 2 operations, the database file lies unencrypted on the disk, and NOT in memory. Also, note that the database file is \fBunencrypted on creation\fR. diff --git a/buku.py b/buku.py index 181f1f0..02865f9 100755 --- a/buku.py +++ b/buku.py @@ -34,6 +34,7 @@ import signal import sqlite3 import sys import threading +import time import urllib3 from urllib3.util import parse_url, make_headers import webbrowser @@ -1934,8 +1935,6 @@ class BukuDb: True on success, False on failure. """ - import time - count = 0 timestamp = str(int(time.time())) arguments = [] @@ -2165,7 +2164,9 @@ class BukuDb: Path to file to import. tacit : bool, optional If True, no questions asked and folder names are automatically - imported as tags. Default is False. + imported as tags from bookmarks html. + If True, automatic timestamp tag is NOT added. + Default is False. Returns ------- @@ -2174,7 +2175,7 @@ class BukuDb: """ if not tacit: - newtag = input('Specify unique tag for imports (Enter to skip): ') + newtag = gen_auto_tag() else: newtag = None @@ -2207,6 +2208,9 @@ class BukuDb: self.conn.commit() infp.close() + if newtag: + print('\nAuto-generated tag: %s' % newtag) + return True def mergedb(self, path): @@ -2815,6 +2819,21 @@ def prep_tag_search(tags): return tags, search_operator, excluded_tags +def gen_auto_tag(): + """Generate a tag in Year-Month-Date format + + Returns + ------- + str + New tag as YYYYMonDD + """ + + import calendar as cal + + t = time.localtime() + return ('%d%s%02d' % (t.tm_year, cal.month_abbr[t.tm_mon], t.tm_mday)) + + def edit_at_prompt(obj, nav): """Edit and add or update a bookmark.