tests/readlink.py
author Boris Feld <boris.feld@octobus.net>
Fri, 09 Feb 2018 12:48:12 +0100
changeset 35991 04304b779df1
parent 29485 6a98f9408a50
child 45830 c102b704edb5
permissions -rwxr-xr-x
tests: raise a better error when patterns are wrongly formatted It is fairly easy to make mistakes when merging conflict in the pattern file. A common mistake is to forget adding an extra trailing comma changing the length of the tuple. We now detect such error and raise a better error message that helps to find it.

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