Revision 1d3f006b kamaki/cli/commands/pithos.py

b/kamaki/cli/commands/pithos.py
513 513
        add_prefix=ValueArgument('', '--add-prefix', default=''),
514 514
        add_suffix=ValueArgument('', '--add-suffix', default=''),
515 515
        prefix_replace=ValueArgument('', '--prefix-to-replace', default=''),
516
        suffix_replace=ValueArgument('', '--suffix-to-replace', default='')
516
        suffix_replace=ValueArgument('', '--suffix-to-replace', default=''),
517 517
    )
518 518

  
519 519
    def __init__(self, arguments={}):
......
555 555
    def _get_all(self, prefix):
556 556
        return self.client.container_get(prefix=prefix).json
557 557

  
558
    def _get_src_objects(self, src_path):
558
    def _get_src_objects(self, src_path, source_version=None):
559 559
        """Get a list of the source objects to be called
560 560

  
561 561
        :param src_path: (str) source path
......
569 569
        if self['prefix']:
570 570
            return (self._get_all, dict(prefix=src_path))
571 571
        try:
572
            srcobj = self.client.get_object_info(src_path)
572
            srcobj = self.client.get_object_info(
573
                src_path, version=source_version)
573 574
        except ClientError as srcerr:
574 575
            if srcerr.status == 404:
575 576
                raiseCLIError(
......
592 593
        srcobj['name'] = src_path
593 594
        return srcobj
594 595

  
595
    def src_dst_pairs(self, dst_path):
596
        src_iter = self._get_src_objects(self.path)
596
    def src_dst_pairs(self, dst_path, source_version=None):
597
        src_iter = self._get_src_objects(self.path, source_version)
597 598
        src_N = isinstance(src_iter, tuple)
598 599
        add_prefix = self['add_prefix'].strip('/')
599 600

  
......
670 671
        destination_container=ValueArgument(
671 672
            'use it if destination container name contains a : character',
672 673
            ('-D', '--dst-container')),
673
        source_version=ValueArgument(
674
            'copy specific version',
675
            ('-S', '--source-version')),
676 674
        public=ValueArgument('make object publicly accessible', '--public'),
677 675
        content_type=ValueArgument(
678 676
            'change object\'s content type',
......
697 695
        suffix_replace=ValueArgument(
698 696
            'Suffix of src to replace with add_suffix, if matched',
699 697
            '--suffix-to-replace',
700
            default='')
698
            default=''),
699
        source_version=ValueArgument(
700
            'copy specific version',
701
            ('-S', '--source-version'))
701 702
    )
702 703

  
703 704
    @errors.generic.all
......
708 709
        no_source_object = True
709 710
        src_account = self.client.account if (
710 711
            self['destination_account']) else None
711
        for src_obj, dst_obj in self.src_dst_pairs(dst_path):
712
        for src_obj, dst_obj in self.src_dst_pairs(
713
                dst_path, self['source_version']):
712 714
            no_source_object = False
713 715
            self.dst_client.copy_object(
714 716
                src_container=self.client.container,
......
760 762
        destination_container=ValueArgument(
761 763
            'use it if destination container name contains a : character',
762 764
            ('-D', '--dst-container')),
763
        source_version=ValueArgument(
764
            'copy specific version',
765
            '--source-version'),
766 765
        public=ValueArgument('make object publicly accessible', '--public'),
767 766
        content_type=ValueArgument(
768 767
            'change object\'s content type',

Also available in: Unified diff