tests/readlink.py
author Tony Tung <tonytung@fb.com>
Tue, 14 Apr 2015 16:23:54 -0400
changeset 25104 d6453f6fbdba
parent 10282 08a0f04b56bd
child 25660 328739ea70c3
permissions -rwxr-xr-x
shelve: allow --patch and --stat without --list for a single shelf It's annoying having to specify --list and --patch/--stat when all you really want to do is to dump a patch. This creates an explicit --patch/--stat command that is executed if --list is not specified. It ensures that 1) there is only one shelf name specified and 2) that the shelf exists. Then it redirects to the original listcmd code.

#!/usr/bin/env python

import errno, os, sys

for f in sys.argv[1:]:
    try:
        print f, '->', os.readlink(f)
    except OSError, err:
        if err.errno != errno.EINVAL:
            raise
        print f, 'not a symlink'

sys.exit(0)