Add API to generate automatic timestamp tag
The format is: YYYYMonDD where, YYYY - numeric year Mon - month string DD - numeric day of month While importing bookmarks, this tag will be added and reported to user if `--tacit` option is not specified.
This commit is contained in:
parent
b81736b885
commit
e645784748
1
buku.1
1
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.
|
||||
|
27
buku.py
27
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user