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

  • Committer: Tim Marston
  • Date: 2016-05-22 17:12:03 UTC
  • Revision ID: tim@ed.am-20160522171203-y2qa4rnz0233jyul
typo in comment

Show diffs side-by-side

added added

removed removed

115
115
 
116
116
 
117
117
 
 
118
 
118
119
        @staticmethod
119
120
        def expand_home_files( files, recurse ):
120
121
                """Returns a unique, sorted list of relative filenames, calculated from the list
121
122
                provided, which is made up from individual files and directories
122
 
                relative to the CWD.  As directories are found, they may optionally be
123
 
                recursed in to.  Leading path components of any items are alse returned.
124
 
                Specified filenames must exist in the home directory (although they do
125
 
                not have to exist in the repo).
 
123
                relative to the CWD.  Directories are recursed in to as requried, and
 
124
                leading path components of any items are alse returned.  Specified
 
125
                filenames must exist in the home directory (although they may not exist
 
126
                in the repo).
126
127
 
127
128
                This is a modified version of command.expand_files().
128
129
 
133
134
 
134
135
                # iterate through file list
135
136
                for file in files:
136
 
                        ( rel_file, abs_file ) = Command.resolve_homedir_file( file )
137
 
 
138
 
                        # check that file exists in homedir
139
 
                        if not os.path.exists( abs_file ):
140
 
                                raise the.program.FatalError(
141
 
                                        'not found in home directory: %s' % file )
 
137
                        parts = os.path.split( file )
 
138
                        abs_file = os.path.join(
 
139
                                os.path.realpath( parts[ 0 ] ), parts[ 1 ] )
 
140
 
 
141
                        # check the file is in the home directory
 
142
                        if abs_file[ : len( home_dir_prefix ) ] != home_dir_prefix:
 
143
                                raise the.program.FatalError(
 
144
                                        'not under home directory: %s' % abs_file )
 
145
 
 
146
                        # relative file
 
147
                        rel_file = abs_file[ len( home_dir_prefix ) : ]
 
148
 
 
149
                        # check if file exists in home directory
 
150
                        if not os.path.lexists( abs_file ):
 
151
                                raise the.program.FatalError(
 
152
                                        'not found in home directory: %s' % rel_file )
142
153
 
143
154
                        # ensure parent path parts are included
144
155
                        path = rel_file