scripts/unref.py
krempp c6560d39b7 initial import
darcs-hash:20000523101252-92525-e00949e2b4ca204828ff25f835cb80acd5d77ff5.gz
2000-05-23 12:12:52 +02:00

29 lines
707 B
Python
Executable file

#! /usr/bin/python
# recursively print links, Sam K (2000)
import os,string,getopt,sys
def simplif(base,n) :
return os.path.normpath(os.path.join(base,n))
optlist, args = getopt.getopt(sys.argv[1:], "")
n=args[0]
print n
cur=os.path.abspath(".")
i=0
while i<2000 and os.path.islink(os.path.join(cur,n)) :
print "%d-level link : %s -> %s" % (i,n,os.readlink(n))
n2=simplif(os.path.dirname(n),os.readlink(n))
# print " - > %s" % n2
i=i+1
n=n2
if i>=2000 :
print "Circular links : %s / %s " % (cur,args[0])
raise "circular_link"
print "real File : %s" % n
if os.path.isfile(n) :
os.system('ls -lF '+n)
os.system("file "+n)
else :
print "Broken Link !!"