1
# Copyright 2009 Canonical Ltd. This software is licensed under the
1
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
4
# pylint: disable-msg=F0401
170
170
RosettaImportStatus)
171
171
from lp.translations.interfaces.translationgroup import (
172
172
ITranslationGroupSet)
173
from lp.translations.interfaces.translationimportqueue import (
175
from lp.translations.interfaces.translationfileformat import (
176
TranslationFileFormat)
173
177
from lp.translations.interfaces.translationsperson import ITranslationsPerson
174
178
from lp.translations.interfaces.translationtemplatesbuildjob import (
175
179
ITranslationTemplatesBuildJobSource)
2085
2089
translation.is_imported = is_imported
2086
2090
translation.is_current = True
2088
def makeTranslationImportQueueEntry(self, path=None, status=None,
2092
def makeTranslationImportQueueEntry(self, path=None, productseries=None,
2089
2094
sourcepackagename=None,
2091
productseries=None, content=None,
2092
uploader=None, is_published=False):
2095
potemplate=None, content=None,
2096
uploader=None, pofile=None,
2097
format=None, status=None):
2093
2098
"""Create a `TranslationImportQueueEntry`."""
2094
2099
if path is None:
2095
2100
path = self.getUniqueString() + '.pot'
2097
status = RosettaImportStatus.NEEDS_REVIEW
2099
if (sourcepackagename is None and distroseries is None):
2102
for_distro = not (distroseries is None and sourcepackagename is None)
2103
for_project = productseries is not None
2104
has_template = (potemplate is not None)
2105
if has_template and not for_distro and not for_project:
2106
# Copy target from template.
2107
distroseries = potemplate.distroseries
2108
sourcepackagename = potemplate.sourcepackagename
2109
productseries = potemplate.productseries
2111
if sourcepackagename is None and distroseries is None:
2100
2112
if productseries is None:
2101
2113
productseries = self.makeProductSeries()
2111
2123
if content is None:
2112
2124
content = self.getUniqueString()
2114
2125
content_reference = getUtility(ILibraryFileAliasSet).create(
2115
2126
name=os.path.basename(path), size=len(content),
2116
2127
file=StringIO(content), contentType='text/plain')
2130
format = TranslationFileFormat.PO
2133
status = RosettaImportStatus.NEEDS_REVIEW
2118
2135
return TranslationImportQueueEntry(
2119
path=path, status=status, sourcepackagename=sourcepackagename,
2120
distroseries=distroseries, productseries=productseries,
2121
importer=uploader, content=content_reference,
2122
is_published=is_published)
2136
path=path, productseries=productseries, distroseries=distroseries,
2137
sourcepackagename=sourcepackagename, importer=uploader,
2138
content=content_reference, status=status, format=format,
2124
2141
def makeMailingList(self, team, owner):
2125
2142
"""Create a mailing list for the team."""