This commit is contained in:
Shelvacu
2025-05-30 09:13:56 -07:00
committed by Shelvacu on fw
parent 4b6362aab0
commit e656449b2a

View File

@@ -22,6 +22,22 @@ def print_json(**kwargs):
print(json.dumps(kwargs))
def dig(obj, *keys):
for key in keys:
if isinstance(obj, dict):
obj = obj.get(key)
elif (isinstance(obj, list) or isinstance(obj, tuple)) and isinstance(key, int):
if 0 <= key < len(obj):
obj = obj[key]
else:
return None
else:
return None
if obj is None:
return None
return obj
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str)
parser.add_argument("--insecure", default=False, action="store_true")
@@ -92,7 +108,8 @@ try:
assert uid is not None
info(f"about to move {uid} to {args.move_to}")
res = mailbox.move(uid, args.move_to)
assert res[1][1][1] is not None, f"failed to move, {res=}" # type: ignore
info(f"{res=}")
assert dig(res, 0, 0, 0, 0) is not None, f"failed to move" # type: ignore
info(f"done moving, res {res!r}")
with connection() as mailbox: