3 Commits

Author SHA1 Message Date
  John-Mark Gurney eff8493baf add ability to search tags.. giving a tag, return all the tag=value pairs.. 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
4 changed files with 39 additions and 0 deletions
Split View
  1. +2
    -0
      .gitignore
  2. +5
    -0
      ui/ISSUES.md
  3. +15
    -0
      ui/fixtures/cmd.search.json
  4. +17
    -0
      ui/medashare/cli.py

+ 2
- 0
.gitignore View File

@@ -1,3 +1,5 @@
.DS_Store

*.bak
*.pyc



+ 5
- 0
ui/ISSUES.md View File

@@ -0,0 +1,5 @@
Known Issues
============

Assumes files are always native.
Search returns any file that matches as if it was local.

+ 15
- 0
ui/fixtures/cmd.search.json View File

@@ -78,5 +78,20 @@
"title": "search other, mapped properly",
"cmd": [ "search", "file", "+other" ],
"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"
}
]

+ 17
- 0
ui/medashare/cli.py View File

@@ -1574,6 +1574,23 @@ def cmd_search(options, persona, objstr, cache):

_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 ]
#_debprint(repr(searches))



Loading…
Cancel
Save