/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/walker.py

  • Committer: Tim Marston
  • Date: 2014-04-18 14:46:42 UTC
  • Revision ID: tim@ed.am-20140418144642-kr3vmc8fgnxgkbza
implemented symlink substitution and ignore list in status walker (and added
some verbose messages)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
import os
23
 
import stdhome.the as the
24
23
 
25
24
 
26
25
class Walker:
38
37
                walk_list that fall under the directory are skipped.
39
38
                """
40
39
 
41
 
                if the.verbose >= 3: print "walking [%s]" % self.__class__.__name__
42
 
 
43
40
                skip = ''
 
41
 
44
42
                for rel_file in self.walk_list:
45
43
 
46
44
                        # if we're skipping, skip entries in subdirectories, or turn off
62
60
                        # way of knowing what to check.  It could be src_type or dst_type
63
61
                        # (if src_dir or dst_dir was used to generate the walk list) or it
64
62
                        # could be neither (if the walk list came from somewhere else).  But
65
 
                        # it shouldn't matter: we add a path seperateor (os.sep) to the end
66
 
                        # of the filename, so it wuill only match files that are descendents
67
 
                        # of a directory with the name of this file.
 
63
                        # it shouldn't matter.  We adding an os.pathset to the end of the
 
64
                        # filename, so it wuill only match files that are descendents of a
 
65
                        # directory with the name of this file.
68
66
                        if not recurse: skip = rel_file + os.sep
69
67
 
70
68
 
100
98
 
101
99
 
102
100
        @staticmethod
103
 
        def generate_walk_list( rel_file = '', full_dir = None ):
 
101
        def generate_walk_list( full_dir, rel_file = '' ):
104
102
                """Returns a list of files and directories in full_dir, specified as relative
105
103
                files (relative to full_dir), breadth first.
106
104
                """
107
105
 
108
 
                # default place to walk
109
 
                if full_dir is None: full_dir = the.repo.full_dir
110
 
 
111
106
                # ignore some files
112
 
                if rel_file in [ '.bzr', '.bzrignore', '.stdhome', '.stdhomerc' ]:
 
107
                if rel_file in { '.bzr', '.bzrignore', '.stdhome', '.stdhomerc' }:
113
108
                        return list()
114
109
 
115
110
                full_file = os.path.join( full_dir, rel_file )
123
118
                        ret = [ rel_file ] if rel_file != '' else []
124
119
                        for file in os.listdir( full_file ):
125
120
                                ret.extend( Walker.generate_walk_list(
126
 
                                        os.path.join( rel_file, file ), full_dir ) )
 
121
                                        full_dir, os.path.join( rel_file, file ) ) )
127
122
                        return sorted( ret )
128
123
 
129
124
                # other kinds are invalid