Revision 24ff0a35 kamaki/cli/commands/pithos_cli.py

b/kamaki/cli/commands/pithos_cli.py
136 136
            try:
137 137
                (key, val) = p.split('=')
138 138
            except ValueError as err:
139
                raiseCLIError(err, 'Error in --sharing',
139
                raiseCLIError(
140
                    err,
141
                    'Error in --sharing',
140 142
                    details='Incorrect format',
141 143
                    importance=1)
142 144
            if key.lower() not in ('read', 'write'):
......
245 247
        return (dst[0], dst[1]) if len(dst) > 1 else (None, dst[0])
246 248

  
247 249
    def extract_container_and_path(
248
        self,
249
        container_with_path,
250
        path_is_optional=True):
250
            self,
251
            container_with_path,
252
            path_is_optional=True):
251 253
        """Contains all heuristics for deciding what should be used as
252 254
        container or path. Options are:
253 255
        * user string of the form container:path
......
366 368
    def print_objects(self, object_list):
367 369
        limit = int(self['limit']) if self['limit'] > 0 else len(object_list)
368 370
        for index, obj in enumerate(object_list):
369
            if (self['exact_match'] and self.path and (
370
                obj['name'] != self.path) or 'content_type' not in obj):
371
                continue
371
            if self['exact_match'] and self.path and not (
372
                obj['name'] == self.path or 'content_type' in obj):
373
                    continue
372 374
            pretty_obj = obj.copy()
373 375
            index += 1
374 376
            empty_space = ' ' * (len(str(len(object_list))) - len(str(index)))
......
576 578
        if len(r.json) == 1:
577 579
            obj = r.json[0]
578 580
            return [(obj['name'], dst_path or obj['name'])]
579
        return [(
580
            obj['name'],
581
            '%s%s' % (
582
                    dst_path,
583
                    obj['name'][len(self.path) if self['replace'] else 0:])
584
        ) for obj in r.json]
581
        start = len(self.path) if self['replace'] else 0
582
        return [(obj['name'], '%s%s' % (
583
            dst_path,
584
            obj['name'][start:])) for obj in r.json]
585 585

  
586 586
    @errors.generic.all
587 587
    @errors.pithos.connection
......
604 604
                self.container))
605 605

  
606 606
    def main(
607
        self,
608
        source_container___path,
609
        destination_container___path=None):
607
            self,
608
            source_container___path,
609
            destination_container___path=None):
610 610
        super(self.__class__, self)._run(
611 611
            source_container___path,
612 612
            path_is_optional=False)
......
686 686
                self.container))
687 687

  
688 688
    def main(
689
        self,
690
        source_container___path,
691
        destination_container___path=None):
689
            self,
690
            source_container___path,
691
            destination_container___path=None):
692 692
        super(self.__class__, self)._run(
693 693
            source_container___path,
694 694
            path_is_optional=False)
......
1042 1042
            default=False),
1043 1043
        recursive=FlagArgument(
1044 1044
            'Download a remote directory and all its contents',
1045
            '-r, --resursive')
1045
            '-r, --recursive')
1046 1046
    )
1047 1047

  
1048 1048
    def _is_dir(self, remote_dict):
......
1213 1213
    @errors.pithos.object_path
1214 1214
    def _run(self):
1215 1215
        if self.path:
1216
            if self['yes'] or ask_user('Delete %s:%s ?' % (
1217
                self.container,
1218
                self.path)):
1216
            if self['yes'] or ask_user(
1217
                    'Delete %s:%s ?' % (self.container, self.path)):
1219 1218
                self.client.del_object(
1220 1219
                    self.path,
1221 1220
                    until=self['until'],
......
1223 1222
            else:
1224 1223
                print('Aborted')
1225 1224
        else:
1226
            if self['resursive']:
1225
            if self['recursive']:
1227 1226
                ask_msg = 'Delete container contents'
1228 1227
            else:
1229 1228
                ask_msg = 'Delete container'
......
1350 1349
        for perms in permissions:
1351 1350
            splstr = perms.split('=')
1352 1351
            if 'read' == splstr[0]:
1353
                read = [user_or_group.strip() \
1354
                for user_or_group in splstr[1].split(',')]
1352
                read = [ug.strip() for ug in splstr[1].split(',')]
1355 1353
            elif 'write' == splstr[0]:
1356
                write = [user_or_group.strip() \
1357
                for user_or_group in splstr[1].split(',')]
1354
                write = [ug.strip() for ug in splstr[1].split(',')]
1358 1355
            else:
1359
                read = False
1360
                write = False
1361
        if not (read or write):
1362
            msg = 'Usage:\tread=<groups,users> write=<groups,users>'
1363
            raiseCLIError(None, msg)
1356
                msg = 'Usage:\tread=<groups,users> write=<groups,users>'
1357
                raiseCLIError(None, msg)
1364 1358
        return (read, write)
1365 1359

  
1366 1360
    @errors.generic.all
......
1721 1715
    @errors.pithos.connection
1722 1716
    def _run(self):
1723 1717
        accounts = self.client.get_sharing_accounts(marker=self['marker'])
1724
        print_items(accounts if self['detail']
1725
            else [acc['name'] for acc in accounts])
1718
        if self['detail']:
1719
            print_items(accounts)
1720
        else:
1721
            print_items([acc['name'] for acc in accounts])
1726 1722

  
1727 1723
    def main(self):
1728 1724
        super(self.__class__, self)._run()
......
1745 1741
    @errors.pithos.object_path
1746 1742
    def _run(self):
1747 1743
        versions = self.client.get_object_versionlist(self.path)
1748
        print_items([dict(
1749
            id=vitem[0],
1750
            created=strftime('%d-%m-%Y %H:%M:%S', localtime(float(vitem[1])))
1751
            ) for vitem in versions])
1744
        print_items([dict(id=vitem[0], created=strftime(
1745
            '%d-%m-%Y %H:%M:%S',
1746
            localtime(float(vitem[1])))) for vitem in versions])
1752 1747

  
1753 1748
    def main(self, container___path):
1754 1749
        super(store_versions, self)._run(

Also available in: Unified diff