Author | SHA1 | Message | Date |
---|---|---|---|
John-Mark Gurney | eff8493baf |
add ability to search tags.. giving a tag, return all the tag=value pairs..
not sure how I want to handle spaces or escaping other characters. for now, don't |
3 months ago |
John-Mark Gurney | 670ffc953b | standard macos ignore | 3 months ago |
John-Mark Gurney | 84426ff282 | keep track of known issues... | 7 months ago |
@@ -1,3 +1,5 @@ | |||||
.DS_Store | |||||
*.bak | *.bak | ||||
*.pyc | *.pyc | ||||
@@ -0,0 +1,5 @@ | |||||
Known Issues | |||||
============ | |||||
Assumes files are always native. | |||||
Search returns any file that matches as if it was local. |
@@ -78,5 +78,20 @@ | |||||
"title": "search other, mapped properly", | "title": "search other, mapped properly", | ||||
"cmd": [ "search", "file", "+other" ], | "cmd": [ "search", "file", "+other" ], | ||||
"stdout_re": "^/foobar/test.txt\n$" | "stdout_re": "^/foobar/test.txt\n$" | ||||
}, | |||||
{ | |||||
"title": "add tag with space", | |||||
"cmd": [ "modify", "+tag=car baz", "test.txt" ] | |||||
}, | |||||
{ | |||||
"title": "search tags", | |||||
"cmd": [ "search", "tags", "tag" ], | |||||
"stdout": "tag=bar\ntag=car baz\ntag=foo\n" | |||||
}, | |||||
{ | |||||
"title": "search bogus", | |||||
"cmd": [ "search", "lskdjflaskjdoijef", "tag" ], | |||||
"exit": 1, | |||||
"stderr": "unknown search type: 'lskdjflaskjdoijef'\n" | |||||
} | } | ||||
] | ] |
@@ -1574,6 +1574,23 @@ def cmd_search(options, persona, objstr, cache): | |||||
_type = args.pop(0) | _type = args.pop(0) | ||||
if _type == 'tags': | |||||
propmap = aliased(orm.PropertyMapping) | |||||
skeymap = aliased(orm.StringTable) | |||||
svaluemap = aliased(orm.StringTable) | |||||
q = select(skeymap.str, svaluemap.str).where(propmap.keyid == skeymap.id).where(skeymap.str == args[0]).where(propmap.valueid == svaluemap.id).distinct().order_by(svaluemap.str) | |||||
_debprint(repr(q)) | |||||
with objstr._ses() as session: | |||||
for k, v in session.execute(q): | |||||
print('%s=%s' % (k, v)) | |||||
return | |||||
if _type != 'file': | |||||
print('unknown search type: %s' % repr(_type), | |||||
file=sys.stderr) | |||||
sys.exit(1) | |||||
searches = [ (x[0], ) + tuple(x[1:].split('=', 1)) for x in args ] | searches = [ (x[0], ) + tuple(x[1:].split('=', 1)) for x in args ] | ||||
#_debprint(repr(searches)) | #_debprint(repr(searches)) | ||||