~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Undo rename. Again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    ]
11
11
 
12
12
 
13
 
import apt_pkg
14
13
import datetime
15
 
from debian.changelog import (
16
 
    Changelog,
17
 
    ChangelogCreateError,
18
 
    ChangelogParseError,
19
 
    )
20
14
import operator
21
15
import re
22
16
from StringIO import StringIO
609
603
        return PackageDiff(
610
604
            from_source=self, to_source=to_sourcepackagerelease,
611
605
            requester=requester, status=status)
612
 
 
613
 
    def aggregate_changelog(self, since_version):
614
 
        """See `ISourcePackagePublishingHistory`."""
615
 
        if self.changelog is None:
616
 
            return None
617
 
 
618
 
        apt_pkg.InitSystem()
619
 
        chunks = []
620
 
        changelog = self.changelog
621
 
        # The python-debian API for parsing changelogs is pretty awful. The
622
 
        # only useful way of extracting info is to use the iterator on
623
 
        # Changelog and then compare versions.
624
 
        try:
625
 
            for block in Changelog(changelog.read()):
626
 
                version = block._raw_version
627
 
                if (since_version and
628
 
                    apt_pkg.VersionCompare(version, since_version) <= 0):
629
 
                    break
630
 
                # Poking in private attributes is not nice but again the
631
 
                # API is terrible.  We want to ensure that the name/date
632
 
                # line is omitted from these composite changelogs.
633
 
                block._no_trailer = True
634
 
                try:
635
 
                    # python-debian adds an extra blank line to the chunks
636
 
                    # so we'll have to sort this out.
637
 
                    chunks.append(str(block).rstrip())
638
 
                except ChangelogCreateError:
639
 
                    continue
640
 
                if not since_version:
641
 
                    # If a particular version was not requested we just
642
 
                    # return the most recent changelog entry.
643
 
                    break
644
 
        except ChangelogParseError:
645
 
            return None
646
 
 
647
 
        output = "\n\n".join(chunks)
648
 
        return output.decode("utf-8", "replace")