36
36
def gen_missing_files(source, destination):
37
37
"""Generate info on every file in source not in destination.
39
Yields `(source, destination, broken)` tuples, where `broken`
40
means that the destination is a broken symbolic link.
39
Yields `(source, destination)` tuples.
42
41
for name in listdir(source):
43
42
destination_file = join(destination, name)
44
43
if not exists(destination_file):
45
44
source_file = join(source, name)
46
yield source_file, destination_file, islink(destination_file)
45
yield source_file, destination_file,
48
def link(source, destination):
49
"""Symlink source to destination.
51
Assumes destination is missing or broken.
54
if islink(destination):
56
symlink(source, destination)
57
except OSError, error:
59
' Error linking %s: %s\n' % (basename(destination), error))
62
stdout.write('%s -> %s\n' % (
63
sep.join(destination.rsplit(sep, 3)[-3:]), source))
49
66
if __name__ == '__main__':
98
115
realpath(join(options.parent, 'sourcecode')),
99
116
abspath(join(options.target, 'sourcecode')))
101
for target, link, broken in missing_files:
105
symlink(target, link)
106
except OSError, error:
108
' Error linking %s: %s\n' % (basename(link), error))
111
stdout.write('%s -> %s\n' % (
112
sep.join(link.rsplit(sep, 3)[-3:]), target))
118
for source, destination in missing_files:
119
link(source, destination)
121
for folder_name in ('eggs', 'download-cache'):
122
source = join(options.parent, folder_name)
123
destination = join(options.target, folder_name)
124
if not exists(destination):
125
link(source, destination)