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

  • Committer: Tim Marston
  • Date: 2014-03-09 01:57:23 UTC
  • Revision ID: tim@ed.am-20140309015723-kwd7kklc76jq0idr
reduced set of available commands to those implemented

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        """
30
30
 
31
31
        @staticmethod
32
 
        def expand_files( files, recurse = True ):
33
 
                """Returns a unique, sorted list of relative files, calculated from the list
34
 
                provided, which is made up from individual files and directories
35
 
                relative to the CWD (and which must be contained within the home
36
 
                directory, although the files need not actually exist in the home
37
 
                directory).  All files must exist in the repository.  Directories are
38
 
                recursed in to as required.
39
 
 
 
32
        def expand_files( files ):
 
33
                """Returns a unique, sorted list of relative files, calculated from the list of
 
34
                files provided, which is made up from individual files and directories
 
35
                to scan that are all relative to the CWD and must be contained within
 
36
                the home directory.
40
37
                """
41
38
 
42
 
                ret = set()
 
39
                ret = list()
43
40
                home_dir_prefix = os.path.realpath( the.full_home_dir ) + os.sep
44
41
 
45
42
                # iterate through file list
46
43
                for file in files:
47
 
                        parts = os.path.split( file )
48
 
                        abs_file = os.path.join(
49
 
                                os.path.realpath( parts[ 0 ] ), parts[ 1 ] )
 
44
                        abs_file = os.path.realpath( file )
50
45
 
51
46
                        # check the file is in the home directory
52
47
                        if abs_file[ : len( home_dir_prefix ) ] != home_dir_prefix:
53
48
                                raise the.program.FatalError(
54
 
                                        'not under home directory: %s' % abs_file )
 
49
                                        'not in home directory: %s' % abs_file )
55
50
 
56
51
                        # relative file
57
52
                        rel_file = abs_file[ len( home_dir_prefix ) : ]
63
58
                                        'not managed by stdhome: %s' % rel_file )
64
59
 
65
60
                        # append the file or directory tree
66
 
                        ret.update( Walker.generate_walk_list(
67
 
                                the.repo.full_dir, rel_file, recurse ) )
 
61
                        ret.extend( Walker.generate_walk_list(
 
62
                                the.repo.full_dir, rel_file ) )
68
63
 
69
 
                return sorted( set ( ret ) )
 
64
                return ret