readlink.py
17 lines
| 325 B
| text/x-python
|
PythonLexer
/ tests / readlink.py
Gregory Szorc
|
r46434 | #!/usr/bin/env python3 | ||
Thomas Arendsen Hein
|
r5683 | |||
Pulkit Goyal
|
r29485 | from __future__ import absolute_import, print_function | ||
timeless
|
r29175 | |||
Pulkit Goyal
|
r29485 | import errno | ||
import os | ||||
import sys | ||||
Thomas Arendsen Hein
|
r5683 | |||
for f in sys.argv[1:]: | ||||
try: | ||||
timeless
|
r29175 | print(f, '->', os.readlink(f)) | ||
Gregory Szorc
|
r25660 | except OSError as err: | ||
Matt Mackall
|
r10282 | if err.errno != errno.EINVAL: | ||
raise | ||||
timeless
|
r29175 | print(f, '->', f, 'not a symlink') | ||
Thomas Arendsen Hein
|
r5683 | |||
sys.exit(0) | ||||