3 # A rather specialized script to make sure that a symbolic link named
4 # RCS exists pointing to a real RCS directory in a parallel tree
5 # referenced as RCStree in an ancestor directory.
6 # (I use this because I like my RCS files to reside on a physically
14 if os
.path
.islink(rcs
):
15 print '%r is a symlink to %r' % (rcs
, os
.readlink(rcs
))
17 if os
.path
.isdir(rcs
):
18 print '%r is an ordinary directory' % (rcs
,)
20 if os
.path
.exists(rcs
):
21 print '%r is a file?!?!' % (rcs
,)
28 # (1) join(p, down) is the current directory
29 # (2) up is the same directory as p
31 # (3) join(up, down) is the current directory
33 while not os
.path
.isdir(os
.path
.join(p
, rcstree
)):
34 head
, tail
= os
.path
.split(p
)
35 #print 'head = %r; tail = %r' % (head, tail)
37 print 'Sorry, no ancestor dir contains %r' % (rcstree
,)
40 up
= os
.path
.join(os
.pardir
, up
)
41 down
= os
.path
.join(tail
, down
)
42 #print 'p = %r; up = %r; down = %r' % (p, up, down)
43 there
= os
.path
.join(up
, rcstree
)
44 there
= os
.path
.join(there
, down
)
45 there
= os
.path
.join(there
, rcs
)
46 if os
.path
.isdir(there
):
47 print '%r already exists' % (there
, )
49 print 'making %r' % (there
,)
51 print 'making symlink %r -> %r' % (rcs
, there
)
52 os
.symlink(there
, rcs
)
55 if not os
.path
.isdir(p
):
56 head
, tail
= os
.path
.split(p
)