Try to adjust the rate (characters/second)
        of the fragments of the list,
        so that it does not exceed the given ``max_rate``.

        This is done by testing whether some slack
        can be borrowed from the fragment before
        the faster current one.

        If ``aggressive`` is ``True``,
        the slack might be retrieved from the fragment after
        the faster current one,
        if the previous fragment could not contribute enough slack.

def _apply_rate(self, max_rate, aggressive=False):
        """
        Try to adjust the rate (characters/second)
        of the fragments of the list,
        so that it does not exceed the given ``max_rate``.

        This is done by testing whether some slack
        can be borrowed from the fragment before
        the faster current one.

        If ``aggressive`` is ``True``,
        the slack might be retrieved from the fragment after
        the faster current one,
        if the previous fragment could not contribute enough slack.
        """
        self.log(u"Called _apply_rate")
        self.log([u"  Aggressive: %s", aggressive])
        self.log([u"  Max rate:   %.3f", max_rate])
        regular_fragments = list(self.smflist.regular_fragments)
        if len(regular_fragments) <= 1:
            self.log(u"  The list contains at most one regular fragment, returning")
            return
        faster_fragments = [(i, f) for i, f in regular_fragments if (f.rate is not None) and (f.rate >= max_rate + Decimal("0.001"))]
        if len(faster_fragments) == 0:
            self.log(u"  No regular fragment faster than max rate, returning")
            return
        self.log_warn(u"  Some fragments have rate faster than max rate:")
        self.log([u"  %s", [i for i, f in faster_fragments]])
        self.log(u"Fixing rate for faster fragments...")
        for frag_index, fragment in faster_fragments:
            self.smflist.fix_fragment_rate(frag_index, max_rate, aggressive=aggressive)
        self.log(u"Fixing rate for faster fragments... done")
        faster_fragments = [(i, f) for i, f in regular_fragments if (f.rate is not None) and (f.rate >= max_rate + Decimal("0.001"))]
        if len(faster_fragments) > 0:
            self.log_warn(u"  Some fragments still have rate faster than max rate:")
            self.log([u"  %s", [i for i, f in faster_fragments]])