Merge pull request #275 from rachmadaniHaryono/feature/append-tag-on-import
Feature/append tag on import
This commit is contained in:
commit
421a4e993f
26
buku.py
26
buku.py
@ -2272,15 +2272,16 @@ class BukuDb:
|
||||
else:
|
||||
newtag = None
|
||||
|
||||
if not tacit:
|
||||
append_tags_resp = input('Append tags when bookmark exist? (n/y): ')
|
||||
else:
|
||||
append_tags_resp = 'n'
|
||||
|
||||
items = []
|
||||
if filepath.endswith('.md'):
|
||||
for item in import_md(filepath=filepath, newtag=newtag):
|
||||
self.add_rec(*item)
|
||||
|
||||
self.conn.commit()
|
||||
|
||||
items = import_md(filepath=filepath, newtag=newtag)
|
||||
elif filepath.endswith('org'):
|
||||
for item in import_org(filepath=filepath, newtag=newtag):
|
||||
self.add_rec(*item)
|
||||
items = import_org(filepath=filepath, newtag=newtag)
|
||||
|
||||
else:
|
||||
try:
|
||||
@ -2300,11 +2301,16 @@ class BukuDb:
|
||||
resp = 'y'
|
||||
|
||||
add_parent_folder_as_tag = (resp == 'y')
|
||||
for item in import_html(soup, add_parent_folder_as_tag, newtag):
|
||||
self.add_rec(*item)
|
||||
items = import_html(soup, add_parent_folder_as_tag, newtag)
|
||||
infp.close()
|
||||
|
||||
for item in items:
|
||||
add_rec_res = self.add_rec(*item)
|
||||
if add_rec_res == -1 and append_tags_resp == 'y':
|
||||
rec_id = self.get_rec_id(item[0])
|
||||
self.append_tag_at_index(rec_id, item[2])
|
||||
|
||||
self.conn.commit()
|
||||
infp.close()
|
||||
|
||||
if newtag:
|
||||
print('\nAuto-generated tag: %s' % newtag)
|
||||
|
Loading…
Reference in New Issue
Block a user