Revision 73bf1f64 kamaki/cli/commands/pithos.py

b/kamaki/cli/commands/pithos.py
1206 1206
                            parsed_name, self.container)])
1207 1207
        else:
1208 1208
            #  Remote object is just a file
1209
            if path.exists(local_path) and not self['resume']:
1210
                raise CLIError(
1211
                    'Cannot overwrite local file %s' % (local_path),
1212
                    details=['To overwrite/resume, use  %s' % (
1213
                        self.arguments['resume'].lvalue)])
1209
            if path.exists(local_path):
1210
                if not self['resume']:
1211
                    raise CLIError(
1212
                        'Cannot overwrite local file %s' % (local_path),
1213
                        details=['To overwrite/resume, use  %s' % (
1214
                            self.arguments['resume'].lvalue)])
1215
            elif '/' in local_path[1:-1]:
1216
                dirs = [p for p in local_path.split('/') if p]
1217
                pref = '/' if local_path.startswith('/') else ''
1218
                for d in dirs[:-1]:
1219
                    pref += d
1220
                    if not path.exists(pref):
1221
                        ret.append((None, d, None))
1222
                    elif not path.isdir(pref):
1223
                        raise CLIError(
1224
                            'Failed to use %s as a destination' % local_path,
1225
                            importance=3,
1226
                            details=[
1227
                                'Local file %s is not a directory' % pref,
1228
                                'Destination prefix must consist of '
1229
                                'directories or non-existing names',
1230
                                'Either remove the file, or choose another '
1231
                                'destination'])
1214 1232
            ret.append((rpath, local_path, self['resume']))
1215 1233
        for r, l, resume in ret:
1216 1234
            if r:

Also available in: Unified diff