tests/readlink.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 01 Dec 2017 14:13:55 -0800
changeset 35207 5cc14407a739
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
amend: make a copy of "extra" to avoid mutating an input I don't know of any problems this has caused, it just seems less surprising. Differential Revision: https://phab.mercurial-scm.org/D1575

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