tests/readlink.py
author Augie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 15:53:22 -0500
changeset 14963 c035f1c53e39
parent 10282 08a0f04b56bd
child 25660 328739ea70c3
permissions -rwxr-xr-x
subrepo: use safehasattr instead of hasattr Some of these instances could be rewritten as clever getattr(x, y, default) ladders, but that felt like it impeded readability too much to be worth the modest efficiency gain.

#!/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)