Merge ~cjwatson/launchpad:unsixify-translations into launchpad:master
- Git
- lp:~cjwatson/launchpad
- unsixify-translations
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 291d7006c71ab9cabb4e7feacb56a37cdbe3ef98 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:unsixify-translations |
Merge into: | launchpad:master |
Diff against target: |
384 lines (+28/-56) 15 files modified
lib/lp/translations/browser/pofile.py (+1/-2) lib/lp/translations/doc/poexport-language-pack.rst (+1/-1) lib/lp/translations/doc/potemplate.rst (+3/-3) lib/lp/translations/doc/potranslation.rst (+0/-11) lib/lp/translations/doc/translationimportqueue.rst (+1/-3) lib/lp/translations/doc/translations-export-to-branch.rst (+1/-1) lib/lp/translations/model/pomsgid.py (+1/-3) lib/lp/translations/model/potranslation.py (+1/-8) lib/lp/translations/tests/test_translationimportqueue.py (+1/-2) lib/lp/translations/utilities/doc/gettext_po_parser.rst (+1/-1) lib/lp/translations/utilities/gettext_po_parser.py (+5/-5) lib/lp/translations/utilities/tests/test_file_importer.py (+7/-8) lib/lp/translations/utilities/translation_import.py (+1/-2) lib/lp/translations/utilities/translationmerger.py (+0/-3) lib/lp/translations/utilities/xpi_header.py (+4/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jürgen Gmach | Approve | ||
Review via email: mp+442910@code.launchpad.net |
Commit message
Remove six from lp.translations
Description of the change
To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/translations/browser/pofile.py b/lib/lp/translations/browser/pofile.py | |||
2 | index fa958c2..b095a66 100644 | |||
3 | --- a/lib/lp/translations/browser/pofile.py | |||
4 | +++ b/lib/lp/translations/browser/pofile.py | |||
5 | @@ -17,7 +17,6 @@ import os.path | |||
6 | 17 | import re | 17 | import re |
7 | 18 | from urllib.parse import urlencode | 18 | from urllib.parse import urlencode |
8 | 19 | 19 | ||
9 | 20 | import six | ||
10 | 21 | from lazr.restful.utils import smartquote | 20 | from lazr.restful.utils import smartquote |
11 | 22 | from zope.component import getUtility | 21 | from zope.component import getUtility |
12 | 23 | from zope.publisher.browser import FileUpload | 22 | from zope.publisher.browser import FileUpload |
13 | @@ -596,7 +595,7 @@ class POFileTranslateView(BaseTranslationView, POFileMetadataViewMixin): | |||
14 | 596 | self.user is not None | 595 | self.user is not None |
15 | 597 | and translations_person.translations_relicensing_agreement is None | 596 | and translations_person.translations_relicensing_agreement is None |
16 | 598 | ): | 597 | ): |
18 | 599 | url = six.ensure_text(str(self.request.URL), "US-ASCII", "replace") | 598 | url = str(self.request.URL) |
19 | 600 | if self.request.get("QUERY_STRING", None): | 599 | if self.request.get("QUERY_STRING", None): |
20 | 601 | url = url + "?" + self.request["QUERY_STRING"] | 600 | url = url + "?" + self.request["QUERY_STRING"] |
21 | 602 | 601 | ||
22 | diff --git a/lib/lp/translations/doc/poexport-language-pack.rst b/lib/lp/translations/doc/poexport-language-pack.rst | |||
23 | index 751ace6..d4067a3 100644 | |||
24 | --- a/lib/lp/translations/doc/poexport-language-pack.rst | |||
25 | +++ b/lib/lp/translations/doc/poexport-language-pack.rst | |||
26 | @@ -98,7 +98,7 @@ And one of the included .po files look like what we expected. | |||
27 | 98 | >>> fh = tarfile.extractfile( | 98 | >>> fh = tarfile.extractfile( |
28 | 99 | ... "rosetta-hoary/es/LC_MESSAGES/evolution-2.2.po" | 99 | ... "rosetta-hoary/es/LC_MESSAGES/evolution-2.2.po" |
29 | 100 | ... ) | 100 | ... ) |
31 | 101 | >>> print(six.ensure_text(fh.readline())) | 101 | >>> print(fh.readline().decode()) |
32 | 102 | # traducción de es.po al Spanish | 102 | # traducción de es.po al Spanish |
33 | 103 | 103 | ||
34 | 104 | 104 | ||
35 | diff --git a/lib/lp/translations/doc/potemplate.rst b/lib/lp/translations/doc/potemplate.rst | |||
36 | index 92146d6..f302f86 100644 | |||
37 | --- a/lib/lp/translations/doc/potemplate.rst | |||
38 | +++ b/lib/lp/translations/doc/potemplate.rst | |||
39 | @@ -607,7 +607,7 @@ The *-es.po file is indeed the Spanish translation... | |||
40 | 607 | >>> file_content = tarfile.extractfile( | 607 | >>> file_content = tarfile.extractfile( |
41 | 608 | ... "evolution-2.2/evolution-2.2-es.po" | 608 | ... "evolution-2.2/evolution-2.2-es.po" |
42 | 609 | ... ) | 609 | ... ) |
44 | 610 | >>> print(six.ensure_text(file_content.readline())) | 610 | >>> print(file_content.readline().decode()) |
45 | 611 | # traducción de es.po al Spanish | 611 | # traducción de es.po al Spanish |
46 | 612 | 612 | ||
47 | 613 | And GNU tar can cope with it. | 613 | And GNU tar can cope with it. |
48 | @@ -615,7 +615,7 @@ And GNU tar can cope with it. | |||
49 | 615 | >>> from lp.services.helpers import simple_popen2 | 615 | >>> from lp.services.helpers import simple_popen2 |
50 | 616 | >>> contents = simple_popen2(["tar", "ztf", "-"], tarfile_bytes) | 616 | >>> contents = simple_popen2(["tar", "ztf", "-"], tarfile_bytes) |
51 | 617 | >>> for line in sorted(contents.splitlines()): | 617 | >>> for line in sorted(contents.splitlines()): |
53 | 618 | ... print(six.ensure_text(line)) | 618 | ... print(line.decode()) |
54 | 619 | ... | 619 | ... |
55 | 620 | evolution-2.2/ | 620 | evolution-2.2/ |
56 | 621 | evolution-2.2/evolution-2.2-es.po | 621 | evolution-2.2/evolution-2.2-es.po |
57 | @@ -629,5 +629,5 @@ And GNU tar can cope with it. | |||
58 | 629 | ... ["tar", "zxfO", "-", "evolution-2.2/evolution-2.2-es.po"], | 629 | ... ["tar", "zxfO", "-", "evolution-2.2/evolution-2.2-es.po"], |
59 | 630 | ... tarfile_bytes, | 630 | ... tarfile_bytes, |
60 | 631 | ... ) | 631 | ... ) |
62 | 632 | >>> print(six.ensure_text(pofile).split("\n")[0]) | 632 | >>> print(pofile.decode().split("\n")[0]) |
63 | 633 | # traducción de es.po al Spanish | 633 | # traducción de es.po al Spanish |
64 | diff --git a/lib/lp/translations/doc/potranslation.rst b/lib/lp/translations/doc/potranslation.rst | |||
65 | index 7c1286b..8b44fc3 100644 | |||
66 | --- a/lib/lp/translations/doc/potranslation.rst | |||
67 | +++ b/lib/lp/translations/doc/potranslation.rst | |||
68 | @@ -30,14 +30,3 @@ doesn't already exist, use POTranslation.getOrCreateTranslation. | |||
69 | 30 | >>> got = POTranslation.getOrCreateTranslation("In Xanadu did Kubla Khan") | 30 | >>> got = POTranslation.getOrCreateTranslation("In Xanadu did Kubla Khan") |
70 | 31 | >>> print(got.translation) | 31 | >>> print(got.translation) |
71 | 32 | In Xanadu did Kubla Khan | 32 | In Xanadu did Kubla Khan |
72 | 33 | |||
73 | 34 | If you want to pass non-ascii characters to either of these, it had better be | ||
74 | 35 | either UTF-8 string or, better, a unicode object. | ||
75 | 36 | |||
76 | 37 | >>> got = POTranslation.getOrCreateTranslation(b"\xc3\x81") | ||
77 | 38 | >>> got = POTranslation.getOrCreateTranslation("\u00c2") | ||
78 | 39 | |||
79 | 40 | >>> got = POTranslation.getOrCreateTranslation(b"\xc0") | ||
80 | 41 | Traceback (most recent call last): | ||
81 | 42 | ... | ||
82 | 43 | UnicodeDecodeError: 'utf...8' codec can't decode byte 0xc0 in position... | ||
83 | diff --git a/lib/lp/translations/doc/translationimportqueue.rst b/lib/lp/translations/doc/translationimportqueue.rst | |||
84 | index 3801c11..edf81ad 100644 | |||
85 | --- a/lib/lp/translations/doc/translationimportqueue.rst | |||
86 | +++ b/lib/lp/translations/doc/translationimportqueue.rst | |||
87 | @@ -1429,11 +1429,9 @@ bug 138650 for an example). | |||
88 | 1429 | If such bad requests do end up on the import queue, the import queue code will | 1429 | If such bad requests do end up on the import queue, the import queue code will |
89 | 1430 | raise errors about them. | 1430 | raise errors about them. |
90 | 1431 | 1431 | ||
91 | 1432 | >>> import six | ||
92 | 1433 | |||
93 | 1434 | >>> def print_import_failures(import_script): | 1432 | >>> def print_import_failures(import_script): |
94 | 1435 | ... """List failures recorded in an import script instance.""" | 1433 | ... """List failures recorded in an import script instance.""" |
96 | 1436 | ... for reason, entries in six.iteritems(script.failures): | 1434 | ... for reason, entries in script.failures.items(): |
97 | 1437 | ... print(reason) | 1435 | ... print(reason) |
98 | 1438 | ... for entry in entries: | 1436 | ... for entry in entries: |
99 | 1439 | ... print("-> " + entry) | 1437 | ... print("-> " + entry) |
100 | diff --git a/lib/lp/translations/doc/translations-export-to-branch.rst b/lib/lp/translations/doc/translations-export-to-branch.rst | |||
101 | index 4e3507e..f01c7bb 100644 | |||
102 | --- a/lib/lp/translations/doc/translations-export-to-branch.rst | |||
103 | +++ b/lib/lp/translations/doc/translations-export-to-branch.rst | |||
104 | @@ -40,7 +40,7 @@ files into the branches. We mock it up here. | |||
105 | 40 | ... | 40 | ... |
106 | 41 | ... def writeFile(self, path, contents): | 41 | ... def writeFile(self, path, contents): |
107 | 42 | ... self.logger.info("Writing file '%s':" % path) | 42 | ... self.logger.info("Writing file '%s':" % path) |
109 | 43 | ... self.logger.info(six.ensure_text(contents)) | 43 | ... self.logger.info(contents.decode()) |
110 | 44 | ... self.written_files += 1 | 44 | ... self.written_files += 1 |
111 | 45 | ... | 45 | ... |
112 | 46 | ... def lockForCommit(self): | 46 | ... def lockForCommit(self): |
113 | diff --git a/lib/lp/translations/model/pomsgid.py b/lib/lp/translations/model/pomsgid.py | |||
114 | index e00bb54..dd8df23 100644 | |||
115 | --- a/lib/lp/translations/model/pomsgid.py | |||
116 | +++ b/lib/lp/translations/model/pomsgid.py | |||
117 | @@ -3,7 +3,6 @@ | |||
118 | 3 | 3 | ||
119 | 4 | __all__ = ["POMsgID"] | 4 | __all__ = ["POMsgID"] |
120 | 5 | 5 | ||
121 | 6 | import six | ||
122 | 7 | from storm.expr import Func | 6 | from storm.expr import Func |
123 | 8 | from storm.locals import Int, Unicode | 7 | from storm.locals import Int, Unicode |
124 | 9 | from zope.interface import implementer | 8 | from zope.interface import implementer |
125 | @@ -46,8 +45,7 @@ class POMsgID(StormBase): | |||
126 | 46 | IStore(POMsgID) | 45 | IStore(POMsgID) |
127 | 47 | .find( | 46 | .find( |
128 | 48 | POMsgID, | 47 | POMsgID, |
131 | 49 | Func("sha1", POMsgID.msgid) | 48 | Func("sha1", POMsgID.msgid) == Func("sha1", key), |
130 | 50 | == Func("sha1", six.ensure_text(key)), | ||
132 | 51 | ) | 49 | ) |
133 | 52 | .one() | 50 | .one() |
134 | 53 | ) | 51 | ) |
135 | diff --git a/lib/lp/translations/model/potranslation.py b/lib/lp/translations/model/potranslation.py | |||
136 | index c367956..5d0626e 100644 | |||
137 | --- a/lib/lp/translations/model/potranslation.py | |||
138 | +++ b/lib/lp/translations/model/potranslation.py | |||
139 | @@ -3,7 +3,6 @@ | |||
140 | 3 | 3 | ||
141 | 4 | __all__ = ["POTranslation"] | 4 | __all__ = ["POTranslation"] |
142 | 5 | 5 | ||
143 | 6 | import six | ||
144 | 7 | from storm.expr import Func | 6 | from storm.expr import Func |
145 | 8 | from storm.locals import Int, Unicode | 7 | from storm.locals import Int, Unicode |
146 | 9 | from zope.interface import implementer | 8 | from zope.interface import implementer |
147 | @@ -44,8 +43,7 @@ class POTranslation(StormBase): | |||
148 | 44 | IStore(POTranslation) | 43 | IStore(POTranslation) |
149 | 45 | .find( | 44 | .find( |
150 | 46 | POTranslation, | 45 | POTranslation, |
153 | 47 | Func("sha1", POTranslation.translation) | 46 | Func("sha1", POTranslation.translation) == Func("sha1", key), |
152 | 48 | == Func("sha1", six.ensure_text(key)), | ||
154 | 49 | ) | 47 | ) |
155 | 50 | .one() | 48 | .one() |
156 | 51 | ) | 49 | ) |
157 | @@ -60,11 +58,6 @@ class POTranslation(StormBase): | |||
158 | 60 | """Return a POTranslation object for the given translation, or create | 58 | """Return a POTranslation object for the given translation, or create |
159 | 61 | it if it doesn't exist. | 59 | it if it doesn't exist. |
160 | 62 | """ | 60 | """ |
161 | 63 | # If this is not a unicode object, it had better be ASCII or UTF-8. | ||
162 | 64 | # XXX: JeroenVermeulen 2008-06-06 bug=237868: non-ascii str strings | ||
163 | 65 | # should be contained in the parser or the browser code. | ||
164 | 66 | key = six.ensure_text(key) | ||
165 | 67 | |||
166 | 68 | try: | 61 | try: |
167 | 69 | return cls.getByTranslation(key) | 62 | return cls.getByTranslation(key) |
168 | 70 | except NotFoundError: | 63 | except NotFoundError: |
169 | diff --git a/lib/lp/translations/tests/test_translationimportqueue.py b/lib/lp/translations/tests/test_translationimportqueue.py | |||
170 | index c20bf61..8a51550 100644 | |||
171 | --- a/lib/lp/translations/tests/test_translationimportqueue.py | |||
172 | +++ b/lib/lp/translations/tests/test_translationimportqueue.py | |||
173 | @@ -4,7 +4,6 @@ | |||
174 | 4 | import os.path | 4 | import os.path |
175 | 5 | from operator import attrgetter | 5 | from operator import attrgetter |
176 | 6 | 6 | ||
177 | 7 | import six | ||
178 | 8 | import transaction | 7 | import transaction |
179 | 9 | from zope.component import getUtility | 8 | from zope.component import getUtility |
180 | 10 | from zope.security.proxy import removeSecurityProxy | 9 | from zope.security.proxy import removeSecurityProxy |
181 | @@ -330,7 +329,7 @@ class TestGetGuessedPOFile(TestCaseWithFactory): | |||
182 | 330 | ) | 329 | ) |
183 | 331 | queue_entry = self.queue.addOrUpdateEntry( | 330 | queue_entry = self.queue.addOrUpdateEntry( |
184 | 332 | "%s.po" % template_path, | 331 | "%s.po" % template_path, |
186 | 333 | six.ensure_binary(template_name), | 332 | template_name.encode(), |
187 | 334 | True, | 333 | True, |
188 | 335 | self.uploaderperson, | 334 | self.uploaderperson, |
189 | 336 | distroseries=package.distroseries, | 335 | distroseries=package.distroseries, |
190 | diff --git a/lib/lp/translations/utilities/doc/gettext_po_parser.rst b/lib/lp/translations/utilities/doc/gettext_po_parser.rst | |||
191 | index ae8013e..76710a3 100644 | |||
192 | --- a/lib/lp/translations/utilities/doc/gettext_po_parser.rst | |||
193 | +++ b/lib/lp/translations/utilities/doc/gettext_po_parser.rst | |||
194 | @@ -452,7 +452,7 @@ The special symbols and numeric representations of the chars '8', '80' and 'p' | |||
195 | 452 | are decoded correctly. | 452 | are decoded correctly. |
196 | 453 | 453 | ||
197 | 454 | >>> for translation in translation_file.messages[0].translations: | 454 | >>> for translation in translation_file.messages[0].translations: |
199 | 455 | ... print(repr(six.ensure_str(translation))) | 455 | ... print(repr(translation)) |
200 | 456 | ... | 456 | ... |
201 | 457 | '\x07\x08\x0b\x0c\t\x0b\\"\'\n8 8 80 p\n' | 457 | '\x07\x08\x0b\x0c\t\x0b\\"\'\n8 8 80 p\n' |
202 | 458 | 458 | ||
203 | diff --git a/lib/lp/translations/utilities/gettext_po_parser.py b/lib/lp/translations/utilities/gettext_po_parser.py | |||
204 | index 43b5354..a383360 100644 | |||
205 | --- a/lib/lp/translations/utilities/gettext_po_parser.py | |||
206 | +++ b/lib/lp/translations/utilities/gettext_po_parser.py | |||
207 | @@ -17,7 +17,6 @@ import re | |||
208 | 17 | from datetime import datetime, timezone | 17 | from datetime import datetime, timezone |
209 | 18 | from email.utils import parseaddr | 18 | from email.utils import parseaddr |
210 | 19 | 19 | ||
211 | 20 | import six | ||
212 | 21 | from zope import datetime as zope_datetime | 20 | from zope import datetime as zope_datetime |
213 | 22 | from zope.interface import implementer | 21 | from zope.interface import implementer |
214 | 23 | 22 | ||
215 | @@ -61,11 +60,14 @@ class POSyntaxWarning(Warning): | |||
216 | 61 | logging.info(self.message) | 60 | logging.info(self.message) |
217 | 62 | 61 | ||
218 | 63 | def __str__(self): | 62 | def __str__(self): |
220 | 64 | return six.ensure_text(self.message) | 63 | return self.message |
221 | 65 | 64 | ||
222 | 66 | 65 | ||
223 | 67 | def parse_charset(string_to_parse, is_escaped=True): | 66 | def parse_charset(string_to_parse, is_escaped=True): |
224 | 68 | """Return charset used in the given string_to_parse.""" | 67 | """Return charset used in the given string_to_parse.""" |
225 | 68 | if isinstance(string_to_parse, bytes): | ||
226 | 69 | string_to_parse = string_to_parse.decode("UTF-8", "replace") | ||
227 | 70 | |||
228 | 69 | # Scan for the charset in the same way that gettext does. | 71 | # Scan for the charset in the same way that gettext does. |
229 | 70 | default_charset = "UTF-8" | 72 | default_charset = "UTF-8" |
230 | 71 | pattern = r"charset=([^\s]+)" | 73 | pattern = r"charset=([^\s]+)" |
231 | @@ -75,9 +77,7 @@ def parse_charset(string_to_parse, is_escaped=True): | |||
232 | 75 | # Default to UTF-8 if the header still has the default value or | 77 | # Default to UTF-8 if the header still has the default value or |
233 | 76 | # is unknown. | 78 | # is unknown. |
234 | 77 | charset = default_charset | 79 | charset = default_charset |
238 | 78 | match = re.search( | 80 | match = re.search(pattern, string_to_parse) |
236 | 79 | pattern, six.ensure_text(string_to_parse, "UTF-8", "replace") | ||
237 | 80 | ) | ||
239 | 81 | if match is not None and match.group(1) != b"CHARSET": | 81 | if match is not None and match.group(1) != b"CHARSET": |
240 | 82 | charset = match.group(1).strip() | 82 | charset = match.group(1).strip() |
241 | 83 | try: | 83 | try: |
242 | diff --git a/lib/lp/translations/utilities/tests/test_file_importer.py b/lib/lp/translations/utilities/tests/test_file_importer.py | |||
243 | index b33596e..b37590d 100644 | |||
244 | --- a/lib/lp/translations/utilities/tests/test_file_importer.py | |||
245 | +++ b/lib/lp/translations/utilities/tests/test_file_importer.py | |||
246 | @@ -5,7 +5,6 @@ | |||
247 | 5 | 5 | ||
248 | 6 | from textwrap import dedent | 6 | from textwrap import dedent |
249 | 7 | 7 | ||
250 | 8 | import six | ||
251 | 9 | import transaction | 8 | import transaction |
252 | 10 | from zope.component import getUtility | 9 | from zope.component import getUtility |
253 | 11 | from zope.security.proxy import removeSecurityProxy | 10 | from zope.security.proxy import removeSecurityProxy |
254 | @@ -143,7 +142,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
255 | 143 | potemplate = self.factory.makePOTemplate() | 142 | potemplate = self.factory.makePOTemplate() |
256 | 144 | template_entry = self.translation_import_queue.addOrUpdateEntry( | 143 | template_entry = self.translation_import_queue.addOrUpdateEntry( |
257 | 145 | potemplate.path, | 144 | potemplate.path, |
259 | 146 | six.ensure_binary(pot_content), | 145 | pot_content.encode(), |
260 | 147 | by_maintainer, | 146 | by_maintainer, |
261 | 148 | self.importer_person, | 147 | self.importer_person, |
262 | 149 | productseries=potemplate.productseries, | 148 | productseries=potemplate.productseries, |
263 | @@ -172,7 +171,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
264 | 172 | person = person or self.importer_person | 171 | person = person or self.importer_person |
265 | 173 | translation_entry = self.translation_import_queue.addOrUpdateEntry( | 172 | translation_entry = self.translation_import_queue.addOrUpdateEntry( |
266 | 174 | pofile.path, | 173 | pofile.path, |
268 | 175 | six.ensure_binary(po_content), | 174 | po_content.encode(), |
269 | 176 | by_maintainer, | 175 | by_maintainer, |
270 | 177 | person, | 176 | person, |
271 | 178 | productseries=potemplate.productseries, | 177 | productseries=potemplate.productseries, |
272 | @@ -202,7 +201,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
273 | 202 | potemplate = self.factory.makePOTemplate() | 201 | potemplate = self.factory.makePOTemplate() |
274 | 203 | template_entry = self.translation_import_queue.addOrUpdateEntry( | 202 | template_entry = self.translation_import_queue.addOrUpdateEntry( |
275 | 204 | potemplate.path, | 203 | potemplate.path, |
277 | 205 | six.ensure_binary(TEST_TEMPLATE_EXPORTED), | 204 | TEST_TEMPLATE_EXPORTED.encode(), |
278 | 206 | False, | 205 | False, |
279 | 207 | self.importer_person, | 206 | self.importer_person, |
280 | 208 | productseries=potemplate.productseries, | 207 | productseries=potemplate.productseries, |
281 | @@ -467,7 +466,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
282 | 467 | "should be none.", | 466 | "should be none.", |
283 | 468 | ) | 467 | ) |
284 | 469 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( | 468 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( |
286 | 470 | six.ensure_text(TEST_MSGID) | 469 | TEST_MSGID |
287 | 471 | ) | 470 | ) |
288 | 472 | message = potmsgset.getCurrentTranslation( | 471 | message = potmsgset.getCurrentTranslation( |
289 | 473 | po_importer.potemplate, | 472 | po_importer.potemplate, |
290 | @@ -561,7 +560,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
291 | 561 | # Although the message has an error, it should still be stored | 560 | # Although the message has an error, it should still be stored |
292 | 562 | # in the database, though only as a suggestion. | 561 | # in the database, though only as a suggestion. |
293 | 563 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( | 562 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( |
295 | 564 | six.ensure_text(TEST_MSGID_ERROR) | 563 | TEST_MSGID_ERROR |
296 | 565 | ) | 564 | ) |
297 | 566 | message = potmsgset.getLocalTranslationMessages( | 565 | message = potmsgset.getLocalTranslationMessages( |
298 | 567 | po_importer.potemplate, po_importer.pofile.language | 566 | po_importer.potemplate, po_importer.pofile.language |
299 | @@ -593,7 +592,7 @@ class FileImporterTestCase(TestCaseWithFactory): | |||
300 | 593 | po_importer2.importFile() | 592 | po_importer2.importFile() |
301 | 594 | 593 | ||
302 | 595 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( | 594 | potmsgset = po_importer.pofile.potemplate.getPOTMsgSetByMsgIDText( |
304 | 596 | six.ensure_text(TEST_MSGID_ERROR) | 595 | TEST_MSGID_ERROR |
305 | 597 | ) | 596 | ) |
306 | 598 | messages = potmsgset.getLocalTranslationMessages( | 597 | messages = potmsgset.getLocalTranslationMessages( |
307 | 599 | po_importer.pofile.potemplate, po_importer.pofile.language | 598 | po_importer.pofile.potemplate, po_importer.pofile.language |
308 | @@ -665,7 +664,7 @@ class CreateFileImporterTestCase(TestCaseWithFactory): | |||
309 | 665 | po_content = TEST_TRANSLATION_FILE % ("", "foo", "bar") | 664 | po_content = TEST_TRANSLATION_FILE % ("", "foo", "bar") |
310 | 666 | queue_entry = self.translation_import_queue.addOrUpdateEntry( | 665 | queue_entry = self.translation_import_queue.addOrUpdateEntry( |
311 | 667 | pofile.path, | 666 | pofile.path, |
313 | 668 | six.ensure_binary(po_content), | 667 | po_content.encode(), |
314 | 669 | by_maintainer, | 668 | by_maintainer, |
315 | 670 | self.importer_person, | 669 | self.importer_person, |
316 | 671 | productseries=pofile.potemplate.productseries, | 670 | productseries=pofile.potemplate.productseries, |
317 | diff --git a/lib/lp/translations/utilities/translation_import.py b/lib/lp/translations/utilities/translation_import.py | |||
318 | index 1535590..901bbc1 100644 | |||
319 | --- a/lib/lp/translations/utilities/translation_import.py | |||
320 | +++ b/lib/lp/translations/utilities/translation_import.py | |||
321 | @@ -11,7 +11,6 @@ import posixpath | |||
322 | 11 | from datetime import datetime, timezone | 11 | from datetime import datetime, timezone |
323 | 12 | from operator import attrgetter | 12 | from operator import attrgetter |
324 | 13 | 13 | ||
325 | 14 | import six | ||
326 | 15 | import transaction | 14 | import transaction |
327 | 16 | from storm.exceptions import TimeoutError | 15 | from storm.exceptions import TimeoutError |
328 | 17 | from zope.component import getUtility | 16 | from zope.component import getUtility |
329 | @@ -636,7 +635,7 @@ class FileImporter: | |||
330 | 636 | "pomessage": self.format_exporter.exportTranslationMessageData( | 635 | "pomessage": self.format_exporter.exportTranslationMessageData( |
331 | 637 | message | 636 | message |
332 | 638 | ), | 637 | ), |
334 | 639 | "error-message": six.ensure_text(errormsg), | 638 | "error-message": errormsg, |
335 | 640 | } | 639 | } |
336 | 641 | ) | 640 | ) |
337 | 642 | 641 | ||
338 | diff --git a/lib/lp/translations/utilities/translationmerger.py b/lib/lp/translations/utilities/translationmerger.py | |||
339 | index 297f54a..2925e1e 100644 | |||
340 | --- a/lib/lp/translations/utilities/translationmerger.py | |||
341 | +++ b/lib/lp/translations/utilities/translationmerger.py | |||
342 | @@ -10,7 +10,6 @@ __all__ = [ | |||
343 | 10 | 10 | ||
344 | 11 | from operator import methodcaller | 11 | from operator import methodcaller |
345 | 12 | 12 | ||
346 | 13 | import six | ||
347 | 14 | from storm.locals import ClassAlias, Store | 13 | from storm.locals import ClassAlias, Store |
348 | 15 | from zope.component import getUtility | 14 | from zope.component import getUtility |
349 | 16 | from zope.security.proxy import removeSecurityProxy | 15 | from zope.security.proxy import removeSecurityProxy |
350 | @@ -316,8 +315,6 @@ class MessageSharingMerge(LaunchpadScript): | |||
351 | 316 | sourcepackagename=sourcepackagename, | 315 | sourcepackagename=sourcepackagename, |
352 | 317 | ) | 316 | ) |
353 | 318 | template_regex = self.options.template_names | 317 | template_regex = self.options.template_names |
354 | 319 | if template_regex is not None: | ||
355 | 320 | template_regex = six.ensure_text(template_regex) | ||
356 | 321 | equivalence_classes = subset.groupEquivalentPOTemplates(template_regex) | 318 | equivalence_classes = subset.groupEquivalentPOTemplates(template_regex) |
357 | 322 | 319 | ||
358 | 323 | class_count = len(equivalence_classes) | 320 | class_count = len(equivalence_classes) |
359 | diff --git a/lib/lp/translations/utilities/xpi_header.py b/lib/lp/translations/utilities/xpi_header.py | |||
360 | index b1aa348..cfabddc 100644 | |||
361 | --- a/lib/lp/translations/utilities/xpi_header.py | |||
362 | +++ b/lib/lp/translations/utilities/xpi_header.py | |||
363 | @@ -9,7 +9,6 @@ import io | |||
364 | 9 | from email.utils import parseaddr | 9 | from email.utils import parseaddr |
365 | 10 | 10 | ||
366 | 11 | import defusedxml.cElementTree as cElementTree | 11 | import defusedxml.cElementTree as cElementTree |
367 | 12 | import six | ||
368 | 13 | from zope.interface import implementer | 12 | from zope.interface import implementer |
369 | 14 | 13 | ||
370 | 15 | from lp.translations.interfaces.translationcommonformat import ( | 14 | from lp.translations.interfaces.translationcommonformat import ( |
371 | @@ -65,9 +64,11 @@ class XpiHeader: | |||
372 | 65 | # Both cElementTree and elementtree fail when trying to parse | 64 | # Both cElementTree and elementtree fail when trying to parse |
373 | 66 | # proper unicode strings. Use our raw input instead. | 65 | # proper unicode strings. Use our raw input instead. |
374 | 67 | try: | 66 | try: |
375 | 67 | raw_content = self._raw_content | ||
376 | 68 | if not isinstance(raw_content, bytes): | ||
377 | 69 | raw_content = raw_content.encode() | ||
378 | 68 | parse = cElementTree.iterparse( | 70 | parse = cElementTree.iterparse( |
381 | 69 | io.BytesIO(six.ensure_binary(self._raw_content)), | 71 | io.BytesIO(raw_content), forbid_dtd=True |
380 | 70 | forbid_dtd=True, | ||
382 | 71 | ) | 72 | ) |
383 | 72 | for event, elem in parse: | 73 | for event, elem in parse: |
384 | 73 | if elem.tag == contributor_tag: | 74 | if elem.tag == contributor_tag: |