42
42
# if dst entity doesn't exist, create directory (no need to recurse,
43
43
# since we're copying the whole directory)
44
44
if dst.type == '_':
45
if the.verbose > 1: self.print_op( rel_file, 'd>_' )
45
if the.verbose >= 2: self.print_op( rel_file, 'd>_' )
46
46
shutil.copytree( src.file, dst.file, True )
48
48
# if dst entity is a directory, copy permissions, as required (and
50
50
elif dst.type == 'd':
51
51
# TODO: should check permission and only do as necessary
52
if the.verbose > 1: self.print_op( rel_file, 'd>d' )
52
if the.verbose >= 2: self.print_op( rel_file, 'd>d' )
53
53
shutil.copystat( src.file, dst.file )
57
57
# acceptable substitute, just recurse
58
58
elif dst.link_type == 'd' and \
59
59
self.accept_list and self.accept_list.match( rel_file ):
60
if the.verbose > 1: self.print_op( rel_file, 'd@d' )
60
if the.verbose >= 2: self.print_op( rel_file, 'd@d' )
63
63
# if dst entity is a file or symlink in home dir, replace it with
64
64
# directory (no need to recurse, since we're copying the whole
66
66
elif dst.type == 'f' or dst.type == 'l':
67
if the.verbose > 1: self.print_op( rel_file, 'd>' + dst.type )
67
if the.verbose >= 2: self.print_op( rel_file, 'd>' + dst.type )
68
68
os.unlink( dst.file )
69
69
shutil.copytree( src.file, dst.file, True )
77
77
# if dst entity doesn't exist, copy file
78
78
if dst.type == '_':
79
if the.verbose > 1: self.print_op( rel_file, 'f>_' )
79
if the.verbose >= 2: self.print_op( rel_file, 'f>_' )
80
80
shutil.copy( src.file, dst.file )
81
81
shutil.copystat( src.file, dst.file )
83
83
# if dst entity is a file, replace it only if it differs
84
84
elif dst.type == 'f':
85
85
if not filecmp.cmp( src.file, dst.file ):
86
if the.verbose > 1: self.print_op( rel_file, 'f>f' )
86
if the.verbose >= 2: self.print_op( rel_file, 'f>f' )
87
87
os.unlink( dst.file )
88
88
shutil.copy( src.file, dst.file )
89
89
shutil.copystat( src.file, dst.file )
91
if the.verbose > 1: self.print_op( rel_file, 'f=f' )
91
if the.verbose >= 2: self.print_op( rel_file, 'f=f' )
93
93
# if dst entity is a directory, replace it with file
94
94
elif dst.type == 'd':
95
if the.verbose > 1: self.print_op( rel_file, 'f>d' )
95
if the.verbose >= 2: self.print_op( rel_file, 'f>d' )
96
96
shutil.rmtree( dst.file )
97
97
shutil.copy( src.file, dst.file )
98
98
shutil.copystat( src.file, dst.file )
100
100
# if dst entity is a symlink, replace it with file
101
101
elif dst.type == 'l':
102
if the.verbose > 1: self.print_op( rel_file, 'f>l' )
102
if the.verbose >= 2: self.print_op( rel_file, 'f>l' )
103
103
os.unlink( dst.file )
104
104
shutil.copy( src.file, dst.file )
105
105
shutil.copystat( src.file, dst.file )
113
113
# if dst entity doesn't exist, copy symlink
114
114
if dst.type == '_':
115
if the.verbose > 1: self.print_op( rel_file, 'l>_' )
115
if the.verbose >= 2: self.print_op( rel_file, 'l>_' )
116
116
os.symlink( os.readlink( src.file ), dst.file )
118
118
# if dst entity is a symlink, replace it only if it differs
119
119
elif dst.type == 'l':
120
120
if os.readlink( src.file ) != os.readlink( dst.file ):
121
if the.verbose > 1: self.print_op( rel_file, 'l>l' )
121
if the.verbose >= 2: self.print_op( rel_file, 'l>l' )
122
122
os.unlink( dst.file )
123
123
os.symlink( os.readlink( src.file ), dst.file )
125
if the.verbose > 1: self.print_op( rel_file, 'l=l' )
125
if the.verbose >= 2: self.print_op( rel_file, 'l=l' )
127
127
# if dst entity is a file, replace it with symlink
128
128
elif dst.type == 'f':
129
if the.verbose > 1: self.print_op( rel_file, 'l>f' )
129
if the.verbose >= 2: self.print_op( rel_file, 'l>f' )
130
130
os.unlink( dst.file )
131
131
os.symlink( os.readlink( src.file ), dst.file )
134
134
# directory, and this is an acceptable substitute, just recurse
135
135
elif dst.type == 'd' and src.link_type == 'd' and \
136
136
self.accept_list and self.accept_list.match( rel_file ):
137
if the.verbose > 1: self.print_op( rel_file, 'd@d' )
137
if the.verbose >= 2: self.print_op( rel_file, 'd@d' )
140
140
# if dst entity is a directory, replace it with symlink
141
141
elif dst.type == 'd':
142
if the.verbose > 1: self.print_op( rel_file, 'l>d' )
142
if the.verbose >= 2: self.print_op( rel_file, 'l>d' )
143
143
shutil.rmtree( dst.file )
144
144
os.symlink( os.readlink( src.file ), dst.file )
156
156
# if dst entity is a file or symlink, delete it
157
157
elif dst.type == 'f' or dst.type == 'l':
158
if the.verbose > 1: self.print_op( rel_file, '_>' + dst.type )
158
if the.verbose >= 2: self.print_op( rel_file, '_>' + dst.type )
159
159
os.unlink( dst.file )
161
161
# if dst entity is a directory, delete it
162
162
elif dst.type == 'd':
163
if the.verbose > 1: self.print_op( rel_file, '_>d' )
163
if the.verbose >= 2: self.print_op( rel_file, '_>d' )
164
164
shutil.rmtree( dst.file )