Browse Source

make some handling via uuid workable..

main
John-Mark Gurney 6 months 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 ", "title": "search excludes newfile.txt ",
"cmd": [ "search", "file", "+some=tag", "-ms:tag=random" ], "cmd": [ "search", "file", "+some=tag", "-ms:tag=random" ],
"stdout_re": "^.*test.txt\n$" "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( session.execute(delete(orm.UUIDv5Table).where(
orm.UUIDv5Table.uuid == obj.id)) orm.UUIDv5Table.uuid == obj.id))


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


try: if i.startswith('uuid:'):
objs = objstr.get_metadata(i, persona) obj = objstr.by_id(i[5:])
#print('d:', repr(i), repr(objs), file=_real_stderr) objs = [ obj ]
except FileNotFoundError: else:
print('ERROR: file not found: %s, or invalid tag specification.' % repr(i), file=sys.stderr) try:
sys.exit(1) 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: for j in objs:


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

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


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

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




||||||
x
 
000:0
Loading…
Cancel
Save