44
44
# if dst entity doesn't exist, create directory (no need to recurse,
45
45
# since we're copying the whole directory)
46
46
if dst.type == '_':
47
if the.verbose > 1: self.print_op( rel_file, 'd>_' )
47
if the.verbose > 1: self.print_cp( rel_file, 'd', '_' )
48
48
os.mkdir( dst.file )
49
49
shutil.copystat( src.file, dst.file )
54
54
elif dst.type == 'd':
55
55
# TODO: should check permission and only do as necessary
56
if the.verbose > 1: self.print_op( rel_file, 'd>d' )
56
if the.verbose > 1: self.print_cp( rel_file, 'd', 'd' )
57
57
shutil.copystat( src.file, dst.file )
60
60
# TODO: if dst entity is a symlink to a directory, and rel_file is
61
61
# matched by the acceptable symlinks file matcher, just recurse
62
elif dst.link_type == 'd' and self.accept_list.match( rel_file ):
63
if the.verbose > 1: self.print_op( rel_file, 'd@d' )
62
# elif dst.link_type == 'd' and self.accept_list.match( rel_file ):
63
# if the.verbose > 1: self.print_cp( rel_file, 'd', 'd', '@' )
66
66
# if dst entity is a file or symlink in home dir, replace it with
67
67
# directory (no need to recurse, since we're copying the whole
69
69
elif dst.type == 'f' or dst.type == 'l':
70
if the.verbose > 1: self.print_op( rel_file, 'd>' + dst.type )
70
if the.verbose > 1: self.print_cp( rel_file, 'd', dst.type )
71
71
os.unlink( dst.file )
72
72
os.mkdir( dst.file )
73
73
shutil.copystat( src.file, dst.file )
82
82
# if dst entity doesn't exist, copy file
83
83
if dst.type == '_':
84
if the.verbose > 1: self.print_op( rel_file, 'f>_' )
84
if the.verbose > 1: self.print_cp( rel_file, 'f', '_' )
85
85
shutil.copy( src.file, dst.file )
86
86
shutil.copystat( src.file, dst.file )
88
88
# if dst entity is a file, replace it only if it differs
89
89
elif dst.type == 'f':
90
90
if not filecmp.cmp( src.file, dst.file ):
91
if the.verbose > 1: self.print_op( rel_file, 'f>f' )
91
if the.verbose > 1: self.print_cp( rel_file, 'f', 'f' )
92
92
os.unlink( dst.file )
93
93
shutil.copy( src.file, dst.file )
94
94
shutil.copystat( src.file, dst.file )
96
if the.verbose > 1: self.print_op( rel_file, 'f=f' )
96
if the.verbose > 1: self.print_cp( rel_file, 'f', 'f', '=' )
98
98
# if dst entity is a directory, replace it with file
99
99
elif dst.type == 'd':
100
if the.verbose > 1: self.print_op( rel_file, 'f>d' )
100
if the.verbose > 1: self.print_cp( rel_file, 'f', 'd' )
101
101
shutil.rmtree( dst.file )
102
102
shutil.copy( src.file, dst.file )
103
103
shutil.copystat( src.file, dst.file )
105
105
# if dst entity is a symlink, replace it with file
106
106
elif dst.type == 'l':
107
if the.verbose > 1: self.print_op( rel_file, 'f>l' )
107
if the.verbose > 1: self.print_cp( rel_file, 'f', 'l' )
108
108
os.unlink( dst.file )
109
109
shutil.copy( src.file, dst.file )
110
110
shutil.copystat( src.file, dst.file )
118
118
# if dst entity doesn't exist, copy symlink
119
119
if dst.type == '_':
120
if the.verbose > 1: self.print_op( rel_file, 'l>_' )
120
if the.verbose > 1: self.print_cp( rel_file, 'l', '_' )
121
121
os.symlink( os.readlink( src.file ), dst.file )
123
123
# if dst entity is a symlink, replace it only if it differs
124
124
elif dst.type == 'l':
125
125
if os.readlink( src.file ) != os.readlink( dst.file ):
126
if the.verbose > 1: self.print_op( rel_file, 'l>l' )
126
if the.verbose > 1: self.print_cp( rel_file, 'l', 'l' )
127
127
os.unlink( dst.file )
128
128
os.symlink( os.readlink( src.file ), dst.file )
130
if the.verbose > 1: self.print_op( rel_file, 'l=l' )
130
if the.verbose > 1: self.print_cp( rel_file, 'l', 'l', '=' )
132
132
# if dst entity is a file, replace it with symlink
133
133
elif dst.type == 'f':
134
if the.verbose > 1: self.print_op( rel_file, 'l>f' )
134
if the.verbose > 1: self.print_cp( rel_file, 'l', 'f' )
135
135
os.unlink( dst.file )
136
136
os.symlink( os.readlink( src.file ), dst.file )
138
138
# if dst entity is a directory, replace it with symlink
139
139
elif dst.type == 'd':
140
if the.verbose > 1: self.print_op( rel_file, 'l>d' )
140
if the.verbose > 1: self.print_cp( rel_file, 'l', 'd' )
141
141
shutil.rmtree( dst.file )
142
142
os.symlink( os.readlink( src.file ), dst.file )
154
154
# if dst entity is a file or symlink, delete it
155
elif dst.type == 'f' or dst.type == 'l':
156
if the.verbose > 1: self.print_op( rel_file, '_>' + dst.type )
155
if dst.type == 'f' or dst.type == 'l':
156
if the.verbose > 1: self.print_cp( rel_file, '_', dst.type )
157
157
os.unlink( dst.file )
159
159
# if dst entity is a directory, delete it
160
160
elif dst.type == 'd':
161
if the.verbose > 1: self.print_op( rel_file, '_>d' )
161
if the.verbose > 1: self.print_cp( rel_file, '_', 'd' )
162
162
shutil.rmtree( dst.file )