summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/linktree.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
commit70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7 (patch)
treecf47b67db3753288cfd9fa2adc45e7c5cd2f8741 /Tools/scripts/linktree.py
parenta88854059309667092000da55d4d5a5804267e9f (diff)
downloadcpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.zip
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.gz
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Tools/scripts/linktree.py')
-rwxr-xr-xTools/scripts/linktree.py112
1 files changed, 56 insertions, 56 deletions
diff --git a/Tools/scripts/linktree.py b/Tools/scripts/linktree.py
index 677be39..502873e 100755
--- a/Tools/scripts/linktree.py
+++ b/Tools/scripts/linktree.py
@@ -17,63 +17,63 @@ LINK = '.LINK' # Name of special symlink at the top.
debug = 0
def main():
- if not 3 <= len(sys.argv) <= 4:
- print 'usage:', sys.argv[0], 'oldtree newtree [linkto]'
- return 2
- oldtree, newtree = sys.argv[1], sys.argv[2]
- if len(sys.argv) > 3:
- link = sys.argv[3]
- link_may_fail = 1
- else:
- link = LINK
- link_may_fail = 0
- if not os.path.isdir(oldtree):
- print oldtree + ': not a directory'
- return 1
- try:
- os.mkdir(newtree, 0777)
- except os.error, msg:
- print newtree + ': cannot mkdir:', msg
- return 1
- linkname = os.path.join(newtree, link)
- try:
- os.symlink(os.path.join(os.pardir, oldtree), linkname)
- except os.error, msg:
- if not link_may_fail:
- print linkname + ': cannot symlink:', msg
- return 1
- else:
- print linkname + ': warning: cannot symlink:', msg
- linknames(oldtree, newtree, link)
- return 0
+ if not 3 <= len(sys.argv) <= 4:
+ print 'usage:', sys.argv[0], 'oldtree newtree [linkto]'
+ return 2
+ oldtree, newtree = sys.argv[1], sys.argv[2]
+ if len(sys.argv) > 3:
+ link = sys.argv[3]
+ link_may_fail = 1
+ else:
+ link = LINK
+ link_may_fail = 0
+ if not os.path.isdir(oldtree):
+ print oldtree + ': not a directory'
+ return 1
+ try:
+ os.mkdir(newtree, 0777)
+ except os.error, msg:
+ print newtree + ': cannot mkdir:', msg
+ return 1
+ linkname = os.path.join(newtree, link)
+ try:
+ os.symlink(os.path.join(os.pardir, oldtree), linkname)
+ except os.error, msg:
+ if not link_may_fail:
+ print linkname + ': cannot symlink:', msg
+ return 1
+ else:
+ print linkname + ': warning: cannot symlink:', msg
+ linknames(oldtree, newtree, link)
+ return 0
def linknames(old, new, link):
- if debug: print 'linknames', (old, new, link)
- try:
- names = os.listdir(old)
- except os.error, msg:
- print old + ': warning: cannot listdir:', msg
- return
- for name in names:
- if name not in (os.curdir, os.pardir):
- oldname = os.path.join(old, name)
- linkname = os.path.join(link, name)
- newname = os.path.join(new, name)
- if debug > 1: print oldname, newname, linkname
- if os.path.isdir(oldname) and \
- not os.path.islink(oldname):
- try:
- os.mkdir(newname, 0777)
- ok = 1
- except:
- print newname + \
- ': warning: cannot mkdir:', msg
- ok = 0
- if ok:
- linkname = os.path.join(os.pardir,
- linkname)
- linknames(oldname, newname, linkname)
- else:
- os.symlink(linkname, newname)
+ if debug: print 'linknames', (old, new, link)
+ try:
+ names = os.listdir(old)
+ except os.error, msg:
+ print old + ': warning: cannot listdir:', msg
+ return
+ for name in names:
+ if name not in (os.curdir, os.pardir):
+ oldname = os.path.join(old, name)
+ linkname = os.path.join(link, name)
+ newname = os.path.join(new, name)
+ if debug > 1: print oldname, newname, linkname
+ if os.path.isdir(oldname) and \
+ not os.path.islink(oldname):
+ try:
+ os.mkdir(newname, 0777)
+ ok = 1
+ except:
+ print newname + \
+ ': warning: cannot mkdir:', msg
+ ok = 0
+ if ok:
+ linkname = os.path.join(os.pardir,
+ linkname)
+ linknames(oldname, newname, linkname)
+ else:
+ os.symlink(linkname, newname)
sys.exit(main())