tests/readlink.py
author Yuya Nishihara <yuya@tcha.org>
Sun, 19 Feb 2017 01:16:45 +0900
changeset 31125 3f8f53190d6a
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
chg: deduplicate error handling of ui.system() This moves 'onerr' handling from low-level util.system() to higher level, which seems better API separation.

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