tests/readlink.py
author Augie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 16:07:52 -0500
changeset 14972 bcba68e81a81
parent 10282 08a0f04b56bd
child 25660 328739ea70c3
permissions -rwxr-xr-x
setup3k: use getattr instead of hasattr Note that hasattr is fixed on Python 3, so this is more about being concise and keeping check-code happy than actual correctness of 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)