Code review comment for lp:~henninge/launchpad/recife-bug-611674-convert-imports

Revision history for this message
Henning Eggers (henninge) wrote :

Incremental diff.

1=== modified file 'lib/lp/translations/doc/poimport-script.txt'
2--- lib/lp/translations/doc/poimport-script.txt 2010-09-29 11:53:45 +0000
3+++ lib/lp/translations/doc/poimport-script.txt 2010-10-01 10:15:02 +0000
4@@ -284,7 +284,7 @@
5 >>> esperanto = getUtility(ILanguageSet).getLanguageByCode('eo')
6 >>> suggestions = potemplate['Foo %s'].getLocalTranslationMessages(
7 ... potemplate, esperanto)
8- >>> sorted([sugg.msgstr0.translation for sugg in suggestions])
9+ >>> sorted([suggestion.msgstr0.translation for suggestion in suggestions])
10 [u'Bar', u'Bars']
11
12 Since this last upload was not the upstream one, however, its credits
13
14=== modified file 'lib/lp/translations/utilities/tests/test_file_importer.py'
15--- lib/lp/translations/utilities/tests/test_file_importer.py 2010-09-30 08:51:21 +0000
16+++ lib/lp/translations/utilities/tests/test_file_importer.py 2010-10-01 13:56:41 +0000
17@@ -582,7 +582,6 @@
18
19 UPSTREAM = 0
20 UBUNTU = 1
21- LANGCODE = 'eo'
22
23 POFILE = dedent("""\
24 msgid ""
25@@ -593,13 +592,14 @@
26 "X-Launchpad-Export-Date: 2009-05-14 08:54+0000\\n"
27
28 msgid "Thank You"
29- msgstr "Dankon"
30+ msgstr "Translation"
31 """)
32
33 def setUp(self):
34 super(FileImporterSharingTest, self).setUp()
35 # Create the upstream series and template with a translator.
36- self.translator = self.factory.makeTranslator(self.LANGCODE)
37+ self.language = self.factory.makeLanguage()
38+ self.translator = self.factory.makeTranslator(self.language.code)
39 self.upstream_productseries = self.factory.makeProductSeries()
40 self.upstream_productseries.product.translationgroup = (
41 self.translator.translationgroup)
42@@ -608,12 +608,12 @@
43 self.upstream_template = self.factory.makePOTemplate(
44 productseries=self.upstream_productseries)
45
46- def _makeEntry(self, side, from_upstream=False, uploader=None):
47+ def _makeImportEntry(self, side, from_upstream=False, uploader=None,
48+ no_upstream=False):
49 if side == self.UPSTREAM:
50 potemplate = self.upstream_template
51 else:
52- # Create a template in a source package and link the source
53- # package to the upstream series to enable sharing.
54+ # Create a template in a source package.
55 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
56 distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
57 ubuntu.translation_focus = distroseries
58@@ -622,19 +622,24 @@
59 distroseries=distroseries,
60 sourcepackagename=sourcepackagename,
61 name=self.upstream_template.name)
62- self.factory.makeSourcePackagePublishingHistory(
63- sourcepackagename=sourcepackagename,
64- distroseries=distroseries)
65- sourcepackage = distroseries.getSourcePackage(sourcepackagename)
66- sourcepackage.setPackaging(
67- self.upstream_productseries, self.factory.makePerson())
68+ if not no_upstream:
69+ # Link the source package to the upstream series to
70+ # enable sharing.
71+ self.factory.makeSourcePackagePublishingHistory(
72+ sourcepackagename=sourcepackagename,
73+ distroseries=distroseries)
74+ sourcepackage = distroseries.getSourcePackage(
75+ sourcepackagename)
76+ sourcepackage.setPackaging(
77+ self.upstream_productseries, self.factory.makePerson())
78 pofile = self.factory.makePOFile(
79- self.LANGCODE, potemplate=potemplate, create_sharing=True)
80+ self.language.code, potemplate=potemplate, create_sharing=True)
81 entry = self.factory.makeTranslationImportQueueEntry(
82 potemplate=potemplate, from_upstream=from_upstream,
83 uploader=uploader, content=self.POFILE)
84 entry.potemplate = potemplate
85 entry.pofile = pofile
86+ # The uploaded file is only created in the librarian by a commit.
87 transaction.commit()
88 return entry
89
90@@ -642,7 +647,7 @@
91 # Sanity check that the translator has the right permissions but
92 # others don't.
93 pofile = self.factory.makePOFile(
94- self.LANGCODE, potemplate=self.upstream_template)
95+ self.language.code, potemplate=self.upstream_template)
96 self.assertFalse(
97 pofile.canEditTranslations(self.factory.makePerson()))
98 self.assertTrue(
99@@ -650,7 +655,7 @@
100
101 def test_templates_are_sharing(self):
102 # Sharing between upstream and Ubuntu was set up correctly.
103- entry = self._makeEntry(self.UBUNTU)
104+ entry = self._makeImportEntry(self.UBUNTU)
105 subset = getUtility(IPOTemplateSet).getSharingSubset(
106 distribution=entry.distroseries.distribution,
107 sourcepackagename=entry.sourcepackagename)
108@@ -660,7 +665,7 @@
109
110 def test_share_with_other_side_upstream(self):
111 # An upstream queue entry will be shared with ubuntu.
112- entry = self._makeEntry(self.UPSTREAM)
113+ entry = self._makeImportEntry(self.UPSTREAM)
114 importer = POFileImporter(
115 entry, importers[TranslationFileFormat.PO], None)
116 self.assertTrue(
117@@ -669,7 +674,16 @@
118
119 def test_share_with_other_side_ubuntu(self):
120 # An ubuntu queue entry will not be shared with upstream.
121- entry = self._makeEntry(self.UBUNTU)
122+ entry = self._makeImportEntry(self.UBUNTU)
123+ importer = POFileImporter(
124+ entry, importers[TranslationFileFormat.PO], None)
125+ self.assertFalse(
126+ importer.share_with_other_side,
127+ "Ubuntu import should not share with upstream.")
128+
129+ def test_share_with_other_side_ubuntu_no_upstream(self):
130+ # An ubuntu queue entry cannot share with a non-existent upstream.
131+ entry = self._makeImportEntry(self.UBUNTU, no_upstream=True)
132 importer = POFileImporter(
133 entry, importers[TranslationFileFormat.PO], None)
134 self.assertFalse(
135@@ -679,7 +693,7 @@
136 def test_share_with_other_side_ubuntu_from_package(self):
137 # An ubuntu queue entry that is imported from an upstream package
138 # will be shared with upstream.
139- entry = self._makeEntry(self.UBUNTU, from_upstream=True)
140+ entry = self._makeImportEntry(self.UBUNTU, from_upstream=True)
141 importer = POFileImporter(
142 entry, importers[TranslationFileFormat.PO], None)
143 self.assertTrue(
144@@ -689,7 +703,7 @@
145 def test_share_with_other_side_ubuntu_uploader_upstream_translator(self):
146 # If the uploader in ubuntu has rights on upstream as well, the
147 # translations are shared.
148- entry = self._makeEntry(
149+ entry = self._makeImportEntry(
150 self.UBUNTU, uploader=self.translator.translator)
151 importer = POFileImporter(
152 entry, importers[TranslationFileFormat.PO], None)
153
154=== modified file 'lib/lp/translations/utilities/translation_import.py'
155--- lib/lp/translations/utilities/translation_import.py 2010-09-30 08:51:21 +0000
156+++ lib/lp/translations/utilities/translation_import.py 2010-10-01 14:27:37 +0000
157@@ -490,7 +490,11 @@
158
159 @cachedproperty
160 def translations_are_msgids(self):
161- """Are symbolic msgids being used and these are the real ones?"""
162+ """Are these English strings instead of translations?
163+
164+ If this template uses symbolic message ids, the English POFile
165+ will contain the English original texts that correspond to the
166+ symbols."""
167 return (
168 self.importer.uses_source_string_msgids and
169 self.pofile.language.code == 'en')
170@@ -559,7 +563,6 @@
171 return None
172
173 no_translations = (
174- message_data.translations == [] or
175 message_data.translations is None or
176 not any(message_data.translations))
177 if no_translations:

« Back to merge proposal