Merge pull request #384 from jarun/revert-383-master

Revert "Add --preserve option"
This commit is contained in:
Mischievous Meerkat 2019-05-04 21:39:47 +05:30 committed by GitHub
commit a8acc58c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 44 deletions

View File

@ -195,7 +195,6 @@ EDIT OPTIONS:
clears description, if no arguments
--immutable N disable web-fetch during auto-refresh
N=0: mutable (default), N=1: immutable
--preserve [...] values to preserve for -u
SEARCH OPTIONS:
-s, --sany [...] find records with ANY matching keyword
@ -454,16 +453,10 @@ PROMPT KEYS:
buku (? for help) g > 5 3-2
// remove tags at taglist indices 4 and 6-9 from tags in bookmarks at indices 5 and 2-3
buku (? for help) g 4 9-6 << 5 3-2
37. **Update** URL but **preserve** title
$ buku -u 479 --preserve title --url https://example.com
37. **Update** URL but **preserve** title and comment
$ buku -u 479 --preserve title comment --url https://example.com
38. List bookmarks with **colored output**:
37. List bookmarks with **colored output**:
$ buku --colors oKlxm -p
39. More **help**:
38. More **help**:
$ buku -h
$ man buku

View File

@ -62,7 +62,6 @@ _buku () {
-i --import
--immutable
-n --count
--preserve
-r --sreg
--replace
-s --sany

View File

@ -30,7 +30,6 @@ args=(
'(--np)--np[noninteractive mode]'
'(-o --open)'{-o,--open}'[open bookmarks in browser]'
'(--oa)--oa[browse all search results immediately]'
'(--preserve)--preserve[preserve options]'
'(-p --print)'{-p,--print}'[show bookmark details]'
'(-r --sreg)'{-r,--sreg}'[match a regular exression]:regex'
'(--replace)--replace[replace a tag]:tag to replace'

41
buku
View File

@ -755,8 +755,7 @@ class BukuDb:
tags_in=None,
desc=None,
immutable=-1,
threads=4,
preserve=None):
threads=4):
"""Update an existing record at index.
Update all records if index is 0 and url is not specified.
@ -780,8 +779,6 @@ class BukuDb:
Disable title fetch from web if 1. Default is -1.
threads : int, optional
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
-------
@ -795,23 +792,6 @@ class BukuDb:
tag_modified = False
ret = False
preserve_title = False
preserve_desc = False
if preserve is not None:
if len(preserve) == 0:
preserve = ['url', 'tag', 'comment', 'title']
for option in preserve:
if option == "url":
url = None
elif option in ('tag', 'tags'):
tags_in = None
elif option == "comment":
desc = None
preserve_desc = True
elif option == "title":
title_in = None
preserve_title = True
# Update URL if passed as argument
if url is not None and url != '':
if index == 0:
@ -888,7 +868,7 @@ class BukuDb:
else:
LOGDBG('Title: [%s]', title_to_insert)
if not desc and not preserve_desc:
if not desc:
if not pdesc:
pdesc = ''
query += ' desc = ?,'
@ -900,7 +880,7 @@ class BukuDb:
self.print_rec(index)
return ret
if title_to_insert is not None and not preserve_title:
if title_to_insert is not None:
query += ' metadata = ?,'
arguments += (title_to_insert,)
to_update = True
@ -4783,7 +4763,6 @@ POSITIONAL ARGUMENTS:
addarg('--title', nargs='*', help=hide)
addarg('-c', '--comment', nargs='*', help=hide)
addarg('--immutable', type=int, default=-1, choices={0, 1}, help=hide)
addarg('--preserve', nargs='*', help=hide)
# --------------------
# SEARCH OPTIONS GROUP
@ -5244,7 +5223,7 @@ POSITIONAL ARGUMENTS:
if not args.update:
# Update all records only if search was not opted
if not search_opted:
bdb.update_rec(0, url_in, title_in, tags, desc_in, args.immutable, args.threads, args.preserve)
bdb.update_rec(0, url_in, title_in, tags, desc_in, args.immutable, args.threads)
elif update_search_results and search_results is not None:
if not args.tacit:
print('Updated results:\n')
@ -5259,8 +5238,7 @@ POSITIONAL ARGUMENTS:
tags,
desc_in,
args.immutable,
args.threads,
args.preserve
args.threads
)
# Commit at every 200th removal
@ -5278,8 +5256,7 @@ POSITIONAL ARGUMENTS:
tags,
desc_in,
args.immutable,
args.threads,
args.preserve
args.threads
)
elif '-' in idx:
try:
@ -5296,8 +5273,7 @@ POSITIONAL ARGUMENTS:
tags,
desc_in,
args.immutable,
args.threads,
args.preserve
args.threads
)
else:
for _id in range(vals[0], vals[1] + 1):
@ -5308,8 +5284,7 @@ POSITIONAL ARGUMENTS:
tags,
desc_in,
args.immutable,
args.threads,
args.preserve
args.threads
)
if INTERRUPTED:
break