Merge lp:~danilo/launchpad/bug-545070 into lp:~launchpad/launchpad/recife

Proposed by Данило Шеган on 2010-03-23
Status: Merged
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-545070
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 162 lines (+32/-24)
2 files modified
lib/lp/translations/utilities/tests/test_superfastimports.py (+14/-7)
lib/lp/translations/utilities/translation_import.py (+18/-17)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-545070
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code 2010-03-23 Approve on 2010-03-23
Review via email: mp+21938@code.launchpad.net

Description of the Change

= Bug 545070 =

Clean-up variable and method names in ExistingPOFileInDatabase for the terminology change for imported/current translations.

= Tests =

 bin/test -vvt superfastimports

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/utilities/translation_import.py
  lib/lp/translations/utilities/tests/test_superfastimports.py

All lp.translations tests have passed as well.

To post a comment you must log in.
Brad Crittenden (bac) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/utilities/tests/test_superfastimports.py'
2--- lib/lp/translations/utilities/tests/test_superfastimports.py 2009-09-14 09:12:58 +0000
3+++ lib/lp/translations/utilities/tests/test_superfastimports.py 2010-03-23 14:12:28 +0000
4@@ -45,8 +45,10 @@
5 pofile=self.pofile, is_imported=False)
6 cached_file = ExistingPOFileInDatabase(self.pofile)
7 message_data = self.getTranslationMessageData(current_message)
8- self.assertFalse(cached_file.isAlreadyImportedTheSame(message_data))
9- self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
10+ self.assertFalse(
11+ cached_file.isAlreadyTranslatedTheSameUpstream(message_data))
12+ self.assertTrue(
13+ cached_file.isAlreadyTranslatedTheSameInUbuntu(message_data))
14
15 def test_imported_messages(self):
16 # Make sure current, imported messages are properly
17@@ -55,8 +57,10 @@
18 pofile=self.pofile, is_imported=True)
19 cached_file = ExistingPOFileInDatabase(self.pofile, is_imported=True)
20 message_data = self.getTranslationMessageData(imported_message)
21- self.assertTrue(cached_file.isAlreadyImportedTheSame(message_data))
22- self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
23+ self.assertTrue(
24+ cached_file.isAlreadyTranslatedTheSameUpstream(message_data))
25+ self.assertTrue(
26+ cached_file.isAlreadyTranslatedTheSameInUbuntu(message_data))
27
28 def test_inactive_messages(self):
29 # Make sure non-current messages (i.e. suggestions) are
30@@ -65,8 +69,10 @@
31 pofile=self.pofile, suggestion=True)
32 cached_file = ExistingPOFileInDatabase(self.pofile)
33 message_data = self.getTranslationMessageData(inactive_message)
34- self.assertFalse(cached_file.isAlreadyImportedTheSame(message_data))
35- self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
36+ self.assertFalse(
37+ cached_file.isAlreadyTranslatedTheSameUpstream(message_data))
38+ self.assertFalse(
39+ cached_file.isAlreadyTranslatedTheSameInUbuntu(message_data))
40
41 def test_query_timeout(self):
42 # Test that super-fast-imports doesn't cache anything when it hits
43@@ -84,7 +90,8 @@
44 pofile=self.pofile, is_imported=False)
45 message_data = self.getTranslationMessageData(current_message)
46 cached_file = ExistingPOFileInDatabase(self.pofile)
47- self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
48+ self.assertFalse(cached_file.isAlreadyTranslatedTheSameInUbuntu(
49+ message_data))
50
51 # Restore the old configuration.
52 config.pop('super_fast_timeout')
53
54=== modified file 'lib/lp/translations/utilities/translation_import.py'
55--- lib/lp/translations/utilities/translation_import.py 2010-02-23 08:25:39 +0000
56+++ lib/lp/translations/utilities/translation_import.py 2010-03-23 14:12:28 +0000
57@@ -11,7 +11,6 @@
58
59 import gettextpo
60 import datetime
61-import os
62 import posixpath
63 import pytz
64 from zope.component import getUtility
65@@ -114,15 +113,15 @@
66
67 # Dict indexed by (msgid, context) containing current
68 # TranslationMessageData: doing this for the speed.
69- self.messages = {}
70+ self.ubuntu_messages = {}
71 # Messages which have been seen in the file: messages which exist
72 # in the database, but not in the import, will be expired.
73 self.seen = set()
74
75 # Contains published but inactive translations.
76- self.imported = {}
77+ self.upstream_messages = {}
78
79- # Pre-fill self.messages and self.imported with data.
80+ # Pre-fill self.ubuntu_messages and self.upstream_messages with data.
81 self._fetchDBRows()
82
83 def _fetchDBRows(self):
84@@ -214,9 +213,9 @@
85
86 update_caches = []
87 if is_current:
88- update_caches.append(self.messages)
89+ update_caches.append(self.ubuntu_messages)
90 if is_imported:
91- update_caches.append(self.imported)
92+ update_caches.append(self.upstream_messages)
93
94 for look_at in update_caches:
95 if (msgid, msgid_plural, context) in look_at:
96@@ -248,29 +247,29 @@
97 in the file being imported.
98 """
99 unseen = set()
100- for (singular, plural, context) in self.messages:
101+ for (singular, plural, context) in self.ubuntu_messages:
102 if (singular, plural, context) not in self.seen:
103 unseen.add((singular, plural, context))
104- for (singular, plural, context) in self.imported:
105- if ((singular, plural, context) not in self.messages and
106+ for (singular, plural, context) in self.upstream_messages:
107+ if ((singular, plural, context) not in self.ubuntu_messages and
108 (singular, plural, context) not in self.seen):
109 unseen.add((singular, plural, context))
110 return unseen
111
112- def isAlreadyTranslatedTheSame(self, message):
113+ def isAlreadyTranslatedTheSameInUbuntu(self, message):
114 """Check whether this message is already translated in exactly
115 the same way.
116 """
117 (msgid, plural, context) = (message.msgid_singular,
118 message.msgid_plural,
119 message.context)
120- if (msgid, plural, context) in self.messages:
121- msg_in_db = self.messages[(msgid, plural, context)]
122+ if (msgid, plural, context) in self.ubuntu_messages:
123+ msg_in_db = self.ubuntu_messages[(msgid, plural, context)]
124 return is_identical_translation(msg_in_db, message)
125 else:
126 return False
127
128- def isAlreadyImportedTheSame(self, message):
129+ def isAlreadyTranslatedTheSameUpstream(self, message):
130 """Check whether this translation is already present in DB as
131 'is_imported' translation, and thus needs no changing if we are
132 submitting an imported update.
133@@ -278,12 +277,14 @@
134 (msgid, plural, context) = (message.msgid_singular,
135 message.msgid_plural,
136 message.context)
137- if ((msgid, plural, context) in self.imported) and self.is_imported:
138- msg_in_db = self.imported[(msgid, plural, context)]
139+ if (((msgid, plural, context) in self.upstream_messages) and
140+ self.is_imported):
141+ msg_in_db = self.upstream_messages[(msgid, plural, context)]
142 return is_identical_translation(msg_in_db, message)
143 else:
144 return False
145
146+
147 class TranslationImporter:
148 """Handle translation resources imports."""
149
150@@ -782,10 +783,10 @@
151 # Mark this message as seen in the import
152 self.pofile_in_db.markMessageAsSeen(message)
153 if self.translation_import_queue_entry.is_published:
154- if self.pofile_in_db.isAlreadyImportedTheSame(message):
155+ if self.pofile_in_db.isAlreadyTranslatedTheSameUpstream(message):
156 return
157 else:
158- if self.pofile_in_db.isAlreadyTranslatedTheSame(message):
159+ if self.pofile_in_db.isAlreadyTranslatedTheSameInUbuntu(message):
160 return
161
162 potmsgset = self.getOrCreatePOTMsgSet(message)

Subscribers

People subscribed via source and target branches

to all changes: