Add --preserve option when using --update
This commit is contained in:
parent
a465fd0e46
commit
09f05eb6b8
31
buku
31
buku
@ -755,7 +755,8 @@ class BukuDb:
|
|||||||
tags_in=None,
|
tags_in=None,
|
||||||
desc=None,
|
desc=None,
|
||||||
immutable=-1,
|
immutable=-1,
|
||||||
threads=4):
|
threads=4,
|
||||||
|
preserve=None):
|
||||||
"""Update an existing record at index.
|
"""Update an existing record at index.
|
||||||
|
|
||||||
Update all records if index is 0 and url is not specified.
|
Update all records if index is 0 and url is not specified.
|
||||||
@ -779,6 +780,8 @@ class BukuDb:
|
|||||||
Disable title fetch from web if 1. Default is -1.
|
Disable title fetch from web if 1. Default is -1.
|
||||||
threads : int, optional
|
threads : int, optional
|
||||||
Number of threads to use to refresh full DB. Default is 4.
|
Number of threads to use to refresh full DB. Default is 4.
|
||||||
|
preserve : array of str, optional
|
||||||
|
Values to preserve. Can be "url","title","tag","tags", and "comment"
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -792,6 +795,17 @@ class BukuDb:
|
|||||||
tag_modified = False
|
tag_modified = False
|
||||||
ret = False
|
ret = False
|
||||||
|
|
||||||
|
if preserve is not None:
|
||||||
|
for option in preserve:
|
||||||
|
if option == "url":
|
||||||
|
url = None
|
||||||
|
elif option in ('tag', 'tags'):
|
||||||
|
tags_in = None
|
||||||
|
elif option == "comment":
|
||||||
|
desc = None
|
||||||
|
elif option == "title":
|
||||||
|
title_in = None
|
||||||
|
|
||||||
# Update URL if passed as argument
|
# Update URL if passed as argument
|
||||||
if url is not None and url != '':
|
if url is not None and url != '':
|
||||||
if index == 0:
|
if index == 0:
|
||||||
@ -4763,6 +4777,7 @@ POSITIONAL ARGUMENTS:
|
|||||||
addarg('--title', nargs='*', help=hide)
|
addarg('--title', nargs='*', help=hide)
|
||||||
addarg('-c', '--comment', nargs='*', help=hide)
|
addarg('-c', '--comment', nargs='*', help=hide)
|
||||||
addarg('--immutable', type=int, default=-1, choices={0, 1}, help=hide)
|
addarg('--immutable', type=int, default=-1, choices={0, 1}, help=hide)
|
||||||
|
addarg('--preserve', nargs='*', help=hide)
|
||||||
|
|
||||||
# --------------------
|
# --------------------
|
||||||
# SEARCH OPTIONS GROUP
|
# SEARCH OPTIONS GROUP
|
||||||
@ -5223,7 +5238,7 @@ POSITIONAL ARGUMENTS:
|
|||||||
if not args.update:
|
if not args.update:
|
||||||
# Update all records only if search was not opted
|
# Update all records only if search was not opted
|
||||||
if not search_opted:
|
if not search_opted:
|
||||||
bdb.update_rec(0, url_in, title_in, tags, desc_in, args.immutable, args.threads)
|
bdb.update_rec(0, url_in, title_in, tags, desc_in, args.immutable, args.threads, args.preserve)
|
||||||
elif update_search_results and search_results is not None:
|
elif update_search_results and search_results is not None:
|
||||||
if not args.tacit:
|
if not args.tacit:
|
||||||
print('Updated results:\n')
|
print('Updated results:\n')
|
||||||
@ -5238,7 +5253,8 @@ POSITIONAL ARGUMENTS:
|
|||||||
tags,
|
tags,
|
||||||
desc_in,
|
desc_in,
|
||||||
args.immutable,
|
args.immutable,
|
||||||
args.threads
|
args.threads,
|
||||||
|
args.preserve
|
||||||
)
|
)
|
||||||
|
|
||||||
# Commit at every 200th removal
|
# Commit at every 200th removal
|
||||||
@ -5256,7 +5272,8 @@ POSITIONAL ARGUMENTS:
|
|||||||
tags,
|
tags,
|
||||||
desc_in,
|
desc_in,
|
||||||
args.immutable,
|
args.immutable,
|
||||||
args.threads
|
args.threads,
|
||||||
|
args.preserve
|
||||||
)
|
)
|
||||||
elif '-' in idx:
|
elif '-' in idx:
|
||||||
try:
|
try:
|
||||||
@ -5273,7 +5290,8 @@ POSITIONAL ARGUMENTS:
|
|||||||
tags,
|
tags,
|
||||||
desc_in,
|
desc_in,
|
||||||
args.immutable,
|
args.immutable,
|
||||||
args.threads
|
args.threads,
|
||||||
|
args.preserve
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for _id in range(vals[0], vals[1] + 1):
|
for _id in range(vals[0], vals[1] + 1):
|
||||||
@ -5284,7 +5302,8 @@ POSITIONAL ARGUMENTS:
|
|||||||
tags,
|
tags,
|
||||||
desc_in,
|
desc_in,
|
||||||
args.immutable,
|
args.immutable,
|
||||||
args.threads
|
args.threads,
|
||||||
|
args.preserve
|
||||||
)
|
)
|
||||||
if INTERRUPTED:
|
if INTERRUPTED:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user