tests/readlink.py
author Ryan McElroy <rmcelroy@fb.com>
Tue, 21 Mar 2017 06:50:28 -0700
changeset 31544 e6d4cc29fd60
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
posix: use local reference to removedirs We have a local reference to os.removedirs in module scope, but we still used os.removedirs inside functions. This changes util to use the local reference, which will pave the way for combining duplicated code in future patches.

#!/usr/bin/env python

from __future__ import absolute_import, print_function

import errno
import os
import sys

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

sys.exit(0)