Revision db117cac snf-pithos-tools/pithos/tools/sh.py

b/snf-pithos-tools/pithos/tools/sh.py
256 256
                          default=None, help='remove history until that date')
257 257
        parser.add_option('--format', action='store', dest='format',
258 258
                          default='%d/%m/%Y', help='format to parse until date')
259
        parser.add_option('--delimiter', action='store', type='str',
260
                          dest='delimiter', default=None,
261
                          help='mass delete objects with path staring with <src object> + delimiter')
262
        parser.add_option('-r', action='store_true',
263
                          dest='recursive', default=False,
264
                          help='mass delimiter objects with delimiter /')
259 265
    
260 266
    def execute(self, path):
261 267
        container, sep, object = path.partition('/')
......
265 271
            until = int(_time.mktime(t))
266 272
        
267 273
        if object:
268
            self.client.delete_object(container, object, until)
274
            kwargs = {}
275
            if self.delimiter:
276
                kwargs['delimiter'] = self.delimiter
277
            elif self.recursive:
278
                kwargs['delimiter'] = '/'
279
            self.client.delete_object(container, object, until, **kwargs)
269 280
        else:
270 281
            self.client.delete_container(container, until)
271 282

  
......
447 458
        parser.add_option('--content-type', action='store',
448 459
                          dest='content_type', default=None,
449 460
                          help='change object\'s content type')
461
        parser.add_option('--delimiter', action='store', type='str',
462
                          dest='delimiter', default=None,
463
                          help='mass copy objects with path staring with <src object> + delimiter')
464
        parser.add_option('-r', action='store_true',
465
                          dest='recursive', default=False,
466
                          help='mass copy with delimiter /')
450 467
    
451 468
    def execute(self, src, dst, *args):
452 469
        src_container, sep, src_object = src.partition('/')
......
463 480
            dst_object = dst
464 481
        
465 482
        args = {'content_type':self.content_type} if self.content_type else {}
483
        if self.delimiter:
484
        	args['delimiter'] = self.delimiter
485
        elif self.recursive:
486
        	args['delimiter'] = '/'
466 487
        self.client.copy_object(src_container, src_object, dst_container,
467 488
                                dst_object, meta, self.public, self.version,
468 489
                                **args)
......
576 597
        parser.add_option('--content-type', action='store',
577 598
                          dest='content_type', default=None,
578 599
                          help='change object\'s content type')
600
        parser.add_option('--delimiter', action='store', type='str',
601
                          dest='delimiter', default=None,
602
                          help='mass move objects with path staring with <src object> + delimiter')
603
        parser.add_option('-r', action='store_true',
604
                          dest='recursive', default=False,
605
                          help='mass move objects with delimiter /')
579 606
    
580 607
    def execute(self, src, dst, *args):
581 608
        src_container, sep, src_object = src.partition('/')
......
591 618
            meta[key] = val
592 619
        
593 620
        args = {'content_type':self.content_type} if self.content_type else {}
621
        if self.delimiter:
622
        	args['delimiter'] = self.delimiter
623
        elif self.recursive:
624
        	args['delimiter'] = '/'
594 625
        self.client.move_object(src_container, src_object, dst_container,
595 626
                                dst_object, meta, self.public, **args)
596 627

  

Also available in: Unified diff