Browse Source

add support for valueless searches..

main
John-Mark Gurney 1 year ago
parent
commit
0802947635
2 changed files with 25 additions and 4 deletions
  1. +11
    -1
      ui/fixtures/cmd.search.json
  2. +14
    -3
      ui/medashare/cli.py

+ 11
- 1
ui/fixtures/cmd.search.json View File

@@ -10,7 +10,7 @@
},
{
"title": "add tag b",
"cmd": [ "modify", "+tag=bar", "+dc:creator=John-Mark Gurney", "test.txt" ]
"cmd": [ "modify", "+tag=bar", "+dc:creator=John-Mark Gurney", "+other=baz", "test.txt" ]
},
{
"special": "verify store object cnt",
@@ -31,5 +31,15 @@
"title": "search no tag bar",
"cmd": [ "search", "file", "-tag=bar" ],
"stdout_re": "/newfile.txt\n$"
},
{
"title": "search no other",
"cmd": [ "search", "file", "-other" ],
"stdout_re": "/newfile.txt\n$"
},
{
"title": "search other",
"cmd": [ "search", "file", "+other" ],
"stdout_re": "/test.txt\n$"
}
]

+ 14
- 3
ui/medashare/cli.py View File

@@ -1426,12 +1426,23 @@ def cmd_search(options, persona, objstr, cache):
def testfun(x, s=searches):
try:
for i in s:
op, key, value = i
try:
op, key, value = i
except ValueError:
op, key = i
value = None

if op == '+':
if value not in x[key]:
if value is None:
if key not in x:
return False
elif value not in x[key]:
return False
elif op == '-':
if value in x[key]:
if value is None:
if key in x:
return False
elif value in x[key]:
return False
else:
raise ValueError('unhandled op: %s' % repr(op))


Loading…
Cancel
Save