~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/queue.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-15 02:41:34 UTC
  • mfrom: (13211.2.5 bug-791204)
  • Revision ID: launchpad@pqm.canonical.com-20110615024134-qp73i2q6lo58be2u
[r=gmb][bug=791204] Prepare PackageUpload for handling copy-job
 uploads in queue script and on +queue page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
601
601
        return (PackageUploadCustomFormat.DDTP_TARBALL
602
602
                in self._customFormats)
603
603
 
 
604
    @property
 
605
    def package_name(self):
 
606
        """See `IPackageUpload`."""
 
607
        if self.package_copy_job_id is not None:
 
608
            return self.package_copy_job.package_name
 
609
        elif self.sourcepackagerelease is not None:
 
610
            return self.sourcepackagerelease.sourcepackagename.name
 
611
        else:
 
612
            return None
 
613
 
 
614
    @property
 
615
    def package_version(self):
 
616
        """See `IPackageUpload`."""
 
617
        if self.package_copy_job_id is not None:
 
618
            return self.package_copy_job.metadata["package_version"]
 
619
        elif self.sourcepackagerelease is not None:
 
620
            return self.sourcepackagerelease.version
 
621
        else:
 
622
            return None
 
623
 
 
624
    @property
 
625
    def component_name(self):
 
626
        """See `IPackageUpload`."""
 
627
        if self.package_copy_job_id is not None:
 
628
            return self.package_copy_job.metadata["component_override"]
 
629
        elif self.sourcepackagerelease is not None:
 
630
            return self.sourcepackagerelease.component.name
 
631
        else:
 
632
            return None
 
633
 
 
634
    @property
 
635
    def section_name(self):
 
636
        """See `IPackageUpload`."""
 
637
        if self.package_copy_job_id is not None:
 
638
            return self.package_copy_job.metadata["section_override"]
 
639
        elif self.sourcepackagerelease is not None:
 
640
            return self.sourcepackagerelease.section.name
 
641
        else:
 
642
            return None
 
643
 
604
644
    @cachedproperty
605
645
    def displayname(self):
606
646
        """See `IPackageUpload`."""
607
647
        names = []
608
 
        for queue_source in self.sources:
609
 
            names.append(queue_source.sourcepackagerelease.name)
 
648
        if self.contains_source or self.package_copy_job_id is not None:
 
649
            names.append(self.package_name)
610
650
        for queue_build in self.builds:
611
651
            names.append(queue_build.build.source_package_release.name)
612
652
        for queue_custom in self.customfiles:
622
662
    def displayarchs(self):
623
663
        """See `IPackageUpload`"""
624
664
        archs = []
625
 
        for queue_source in self.sources:
 
665
        if self.contains_source or self.package_copy_job_id is not None:
626
666
            archs.append('source')
627
667
        for queue_build in self.builds:
628
668
            archs.append(queue_build.build.distro_arch_series.architecturetag)
633
673
    @cachedproperty
634
674
    def displayversion(self):
635
675
        """See `IPackageUpload`"""
636
 
        if self.sources:
637
 
            return self.sources[0].sourcepackagerelease.version
638
 
        if self.builds:
639
 
            return self.builds[0].build.source_package_release.version
640
 
        if self.customfiles:
 
676
        package_version = self.package_version
 
677
        if package_version is not None:
 
678
            return package_version
 
679
        elif self.customfiles:
641
680
            return '-'
 
681
        else:
 
682
            return None
642
683
 
643
684
    @cachedproperty
644
685
    def sourcepackagerelease(self):
645
 
        """The source package release related to this queue item.
646
 
 
647
 
        This is currently heuristic but may be more easily calculated later.
648
 
        """
649
 
        if self.sources:
650
 
            return self.sources[0].sourcepackagerelease
651
 
        elif self.builds:
652
 
            return self.builds[0].build.source_package_release
653
 
        else:
654
 
            return None
655
 
 
656
 
    @property
657
 
    def my_source_package_release(self):
658
 
        """The source package release related to this queue item.
659
 
 
660
 
        al-maisan, Wed, 30 Sep 2009 17:58:31 +0200:
661
 
        The cached property version above behaves very finicky in
662
 
        tests and I've had a *hell* of a time revising these and
663
 
        making them pass.
664
 
 
665
 
        In any case, Celso's advice was to stay away from it
666
 
        and I am hence introducing this non-cached variant for
667
 
        usage inside the content class.
668
 
        """
669
 
        if self.sources is not None and bool(self.sources):
670
 
            return self.sources[0].sourcepackagerelease
671
 
        elif self.builds is not None and bool(self.builds):
 
686
        """See `IPackageUpload`."""
 
687
        if self.contains_source:
 
688
            return self.sources[0].sourcepackagerelease
 
689
        elif self.contains_build:
672
690
            return self.builds[0].build.source_package_release
673
691
        else:
674
692
            return None