Browse Source

make some handling via uuid workable..

main
John-Mark Gurney 1 month ago
parent
commit
5d339516dc
3 changed files with 32 additions and 7 deletions
  1. +15
    -0
      ui/fixtures/cmd.parent_obj.json
  2. +11
    -7
      ui/medashare/cli.py
  3. +6
    -0
      ui/medashare/mdb.py

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

@@ -49,5 +49,20 @@
"title": "search excludes newfile.txt ",
"cmd": [ "search", "file", "+some=tag", "-ms:tag=random" ],
"stdout_re": "^.*test.txt\n$"
},
{
"title": "that an obj can be modified by uuid",
"format": [ "cmd" ],
"cmd": [ "modify", "+another=tag", "uuid:{newuuid}" ]
},
{
"title": "and modification works",
"cmd": [ "search", "file", "+another=tag" ],
"stdout_re": "newfile.txt\n$"
},
{
"title": "that a parent obj can be dropped",
"format": [ "cmd" ],
"cmd": [ "drop", "{newuuid}" ]
}
]

+ 11
- 7
ui/medashare/cli.py View File

@@ -554,7 +554,7 @@ class ObjectStore(object):
session.execute(delete(orm.UUIDv5Table).where(
orm.UUIDv5Table.uuid == obj.id))

for j in obj.hashes:
for j in obj.get('hashes', []):
h = self.makehash(j)
session.execute(delete(orm.HashTable).where(
orm.HashTable.hash == h and
@@ -1039,12 +1039,16 @@ def cmd_modify(options, persona, objstr, cache):
for i in options.files:
#print('a:', repr(i), file=_real_stderr)

try:
objs = objstr.get_metadata(i, persona)
#print('d:', repr(i), repr(objs), file=_real_stderr)
except FileNotFoundError:
print('ERROR: file not found: %s, or invalid tag specification.' % repr(i), file=sys.stderr)
sys.exit(1)
if i.startswith('uuid:'):
obj = objstr.by_id(i[5:])
objs = [ obj ]
else:
try:
objs = objstr.get_metadata(i, persona)
#print('d:', repr(i), repr(objs), file=_real_stderr)
except FileNotFoundError:
print('ERROR: file not found: %s, or invalid tag specification.' % repr(i), file=sys.stderr)
sys.exit(1)


for j in objs:


+ 6
- 0
ui/medashare/mdb.py View File

@@ -163,6 +163,12 @@ class MDBase(object):
else:
self._obj[k] = v

def get(self, key, default=None):
try:
return self[key]
except KeyError:
return default

def __getitem__(self, k):
return self._obj[k]



Loading…
Cancel
Save