From c6560d39b7b12c21ebbc00c9168764e18f00179f Mon Sep 17 00:00:00 2001 From: krempp Date: Tue, 23 May 2000 12:12:52 +0200 Subject: [PATCH] initial import darcs-hash:20000523101252-92525-e00949e2b4ca204828ff25f835cb80acd5d77ff5.gz --- unref.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 unref.py diff --git a/unref.py b/unref.py new file mode 100755 index 00000000..072b2e66 --- /dev/null +++ b/unref.py @@ -0,0 +1,29 @@ +#! /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 !!" +