LEFT | RIGHT |
(no file at all) | |
1 #!@PYTHON@ | 1 #!@PYTHON@ |
2 # mass-link.py | 2 # mass-link.py |
3 | 3 |
4 # USAGE: mass-link.py [--prepend-suffix SUFFIX] symbolic | hard SOURCEDIR
DESTDIR FILES | 4 # USAGE: mass-link.py [--prepend-suffix SUFFIX] symbolic | hard SOURCEDIR
DESTDIR FILES |
5 # | 5 # |
6 # create hard or symbolic links to SOURCEDIR/FILES in DESTDIR | 6 # create hard or symbolic links to SOURCEDIR/FILES in DESTDIR |
7 # | 7 # |
8 # If symbolic or hard links are not provided by the operating system, | 8 # If symbolic or hard links are not provided by the operating system, |
9 # copies will be made instead. However, if the operating system | 9 # copies will be made instead. However, if the operating system |
10 # support symbolic or hard links, then this program expects to | 10 # support symbolic or hard links, then this program expects to |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 destfiles = [os.path.join (dest_dir, insert_suffix (relative_path (f))) for f in
sourcefiles] | 74 destfiles = [os.path.join (dest_dir, insert_suffix (relative_path (f))) for f in
sourcefiles] |
75 | 75 |
76 destdirs = set ([os.path.dirname (dest) for dest in destfiles]) | 76 destdirs = set ([os.path.dirname (dest) for dest in destfiles]) |
77 [os.makedirs (d) for d in destdirs if not os.path.exists (d)] | 77 [os.makedirs (d) for d in destdirs if not os.path.exists (d)] |
78 | 78 |
79 def force_link (src,dest): | 79 def force_link (src,dest): |
80 if os.path.exists (dest): | 80 if os.path.exists (dest): |
81 os.remove (dest) | 81 os.remove (dest) |
82 try: | 82 try: |
83 link (src, dest) | 83 link (src, dest) |
84 except OSError, e: # can't use "as" because GUB has python 2.4.5. | 84 except OSError as e: # can't use "as" because GUB has python 2.4.5. |
85 if e.errno == 18: | 85 if e.errno == 18: |
86 shutil.copy (src, dest) | 86 shutil.copy (src, dest) |
87 else: | 87 else: |
88 raise | 88 raise |
89 os.utime (dest, None) | 89 os.utime (dest, None) |
90 | 90 |
91 map (force_link, sourcefiles, destfiles) | 91 list(map (force_link, sourcefiles, destfiles)) |
LEFT | RIGHT |