/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/walker/copy_base.py

  • Committer: Tim Marston
  • Date: 2014-04-12 12:53:54 UTC
  • Revision ID: tim@ed.am-20140412125354-64aysxvaz7nnk8hm
make verbose levels clearer

Show diffs side-by-side

added added

removed removed

31
31
        information.
32
32
        """
33
33
 
34
 
 
35
 
        def __init__( self ):
36
 
                self.check_src_symlinks = False
37
 
                self.check_dst_symlinks = False
38
 
                self.check_dst_ignores = False
 
34
        accept_list = None
39
35
 
40
36
 
41
37
        def process( self, rel_file, src, dst ):
42
38
 
43
 
                # ignore?
44
 
                if self.check_dst_ignores and the.config.ignores.matches( rel_file ):
45
 
                        if the.verbose >= 2:
46
 
                                self.print_op( rel_file, '%s#%s' % ( src.type, dst.type ) )
47
 
                        return True
48
 
 
49
39
                # src entity is directory
50
40
                if src.type == 'd':
51
41
 
65
55
 
66
56
                        # if dst entity is a symlink to a directory, and this is an
67
57
                        # acceptable substitute, just recurse
68
 
                        elif self.check_dst_symlinks and dst.link_type == 'd' and \
69
 
                                        the.config.symlinks.matches( rel_file ):
 
58
                        elif dst.link_type == 'd' and \
 
59
                                        self.accept_list and self.accept_list.match( rel_file ):
70
60
                                if the.verbose >= 2: self.print_op( rel_file, 'd@d' )
71
61
                                return True
72
62
 
140
130
                                os.unlink( dst.file )
141
131
                                os.symlink( os.readlink( src.file ), dst.file )
142
132
 
143
 
                        # if dst entity is a directory...
 
133
                        # if dst entity is a directory, and src entity is a symlink to a
 
134
                        # directory, and this is an acceptable substitute, just recurse
 
135
                        elif dst.type == 'd' and src.link_type == 'd' and \
 
136
                                        self.accept_list and self.accept_list.match( rel_file ):
 
137
                                if the.verbose >= 2: self.print_op( rel_file, 'd@d' )
 
138
                                return True
 
139
 
 
140
                        # if dst entity is a directory, replace it with symlink
144
141
                        elif dst.type == 'd':
145
 
 
146
 
                                # if src entity is a symlink to a directory, and this is an
147
 
                                # acceptable substitute, just recurse
148
 
                                if self.check_src_symlinks and src.link_type == 'd' and \
149
 
                                                the.config.symlinks.matches( rel_file ):
150
 
                                        if the.verbose >= 2: self.print_op( rel_file, 'd@d' )
151
 
                                        return True
152
 
 
153
 
                                # else replace it with a symlink
154
142
                                if the.verbose >= 2: self.print_op( rel_file, 'l>d' )
155
143
                                shutil.rmtree( dst.file )
156
144
                                os.symlink( os.readlink( src.file ), dst.file )