def _composeLink(self, sheet):
        """Produce a link to a `POFile` or `POTemplate`."""
        link = canonical_url(sheet)
        if IPOFile.providedBy(sheet):
            link += self.pofile_link_suffix

        return link
    def _bundle(self, sheets):
        """Bundle `sheets` based on target: `Product` or `SourcePackage`.

        :param sheets: Sequence of `POFile`s and/or `POTemplate`s.
        :return: Dict mapping each targets to a list representing its
            `POFile`s and `POTemplate`s as found in `sheets`.
        """
        targets = {}
        for sheet in sheets:
            if IPOFile.providedBy(sheet):
                template = sheet.potemplate
            else:
                template = sheet

            if template.productseries:
                target = template.productseries.product
            else:
                distroseries = template.distroseries
                sourcepackagename = template.sourcepackagename
                target = distroseries.getSourcePackage(sourcepackagename)

            if target not in targets:
                targets[target] = []

            targets[target].append(sheet)

        return targets
    def _composeLink(self, sheet):
        """Produce a link to a `POFile` or `POTemplate`."""
        link = canonical_url(sheet)
        if IPOFile.providedBy(sheet):
            link += self.pofile_link_suffix

        return link
    def _bundle(self, sheets):
        """Bundle `sheets` based on target: `Product` or `SourcePackage`.

        :param sheets: Sequence of `POFile`s and/or `POTemplate`s.
        :return: Dict mapping each targets to a list representing its
            `POFile`s and `POTemplate`s as found in `sheets`.
        """
        targets = {}
        for sheet in sheets:
            if IPOFile.providedBy(sheet):
                template = sheet.potemplate
            else:
                template = sheet

            if template.productseries:
                target = template.productseries.product
            else:
                distroseries = template.distroseries
                sourcepackagename = template.sourcepackagename
                target = distroseries.getSourcePackage(sourcepackagename)

            if target not in targets:
                targets[target] = []

            targets[target].append(sheet)

        return targets
    def _getTemplate(self, sheet):
        """Return `POTemplate` for `sheet`.

        :param sheet: A `POTemplate` or `POFile`.
        """
        if IPOFile.providedBy(sheet):
            return sheet.potemplate
        else:
            return sheet
    def _getTemplate(self, sheet):
        """Return `POTemplate` for `sheet`.

        :param sheet: A `POTemplate` or `POFile`.
        """
        if IPOFile.providedBy(sheet):
            return sheet.potemplate
        else:
            return sheet
    def _getShortRequestName(self, request):
        """Return a short request name for use in email subjects."""
        if IPOFile.providedBy(request):
            title = '%s translation of %s' % (
                request.language.englishname,
                request.potemplate.name)
            productseries = request.potemplate.productseries
            distroseries = request.potemplate.distroseries
            sourcepackagename = request.potemplate.sourcepackagename
        elif IPOTemplate.providedBy(request):
            title = '%s template' % (request.name)
            productseries = request.productseries
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        elif IProductSeries.providedBy(request):
            title = None
            productseries = request
            distroseries = None
            sourcepackagename = None
        elif ISourcePackage.providedBy(request):
            title = None
            productseries = None
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        else:
            raise AssertionError(
                "We can not figure out short name for this translation "
                "export origin.")

        if productseries is not None:
            root = '%s %s' % (
                productseries.product.displayname,
                productseries.name)
        else:
            root = '%s %s %s' % (
                distroseries.distribution.displayname,
                distroseries.displayname,
                sourcepackagename.name)
        if title is not None:
            return '%s - %s' % (root, title)
        else:
            return root
    def _getShortRequestName(self, request):
        """Return a short request name for use in email subjects."""
        if IPOFile.providedBy(request):
            title = '%s translation of %s' % (request.language.englishname,
                                              request.potemplate.name)
            productseries = request.potemplate.productseries
            distroseries = request.potemplate.distroseries
            sourcepackagename = request.potemplate.sourcepackagename
        elif IPOTemplate.providedBy(request):
            title = '%s template' % (request.name)
            productseries = request.productseries
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        elif IProductSeries.providedBy(request):
            title = None
            productseries = request
            distroseries = None
            sourcepackagename = None
        elif ISourcePackage.providedBy(request):
            title = None
            productseries = None
            distroseries = request.distroseries
            sourcepackagename = request.sourcepackagename
        else:
            raise AssertionError(
                "We can not figure out short name for this translation "
                "export origin.")

        if productseries is not None:
            root = '%s %s' % (productseries.product.displayname,
                              productseries.name)
        else:
            root = '%s %s %s' % (distroseries.distribution.displayname,
                                 distroseries.displayname,
                                 sourcepackagename.name)
        if title is not None:
            return '%s - %s' % (root, title)
        else:
            return root
 def _getLanguage(self, sheet):
     """Return language `sheet` is in, if `sheet` is an `IPOFile`."""
     if IPOFile.providedBy(sheet):
         return sheet.language
     else:
         return None
 def _getLanguage(self, sheet):
     """Return language `sheet` is in, if `sheet` is an `IPOFile`."""
     if IPOFile.providedBy(sheet):
         return sheet.language
     else:
         return None