tests/readlink.py
author Augie Fackler <augie@google.com>
Fri, 06 Mar 2020 13:54:35 -0500
changeset 44480 6aee0647e026
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
nodemap: fix missing r-prefix on regular expression Looking at this regular expression, it's pretty obvious from reading it that it wanted to match literal ., but since the r was missing on the pattern it was matching any character. I guess we're just lucky nothing bad happened as a result. This was automatically fixed by pyupgrade, but I split it out into its own change because it seemed important. Differential Revision: https://phab.mercurial-scm.org/D8254

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