Merge ~cjwatson/launchpad:py3-bytes-formatting into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5e468ef2e57625b76d9e74869216b604baa9a57b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-bytes-formatting
Merge into: launchpad:master
Diff against target: 613 lines (+83/-84)
14 files modified
lib/lp/app/browser/doc/launchpad-search-pages.txt (+6/-7)
lib/lp/archivepublisher/tests/test_sync_signingkeys.py (+14/-14)
lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt (+4/-4)
lib/lp/buildmaster/tests/mock_slaves.py (+1/-1)
lib/lp/services/daemons/tests/test_tachandler.py (+2/-2)
lib/lp/services/librarianserver/doc/upload.txt (+3/-3)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+3/-3)
lib/lp/soyuz/stories/ppa/xx-ppa-files.txt (+12/-12)
lib/lp/translations/doc/poimport-pofile-old-po-imported.txt (+4/-4)
lib/lp/translations/doc/poimport-pofile-syntax-error.txt (+12/-12)
lib/lp/translations/doc/poimport.txt (+10/-10)
lib/lp/translations/doc/rosetta-karma.txt (+4/-4)
lib/lp/translations/doc/rosetta-poimport-script.txt (+6/-6)
lib/lp/translations/utilities/tests/test_translation_importer.py (+2/-2)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398874@code.launchpad.net

Commit message

Avoid b"%s" % str constructions

Description of the change

On Python 3, %s in a bytes format string requires bytes.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/app/browser/doc/launchpad-search-pages.txt b/lib/lp/app/browser/doc/launchpad-search-pages.txt
index ded7f0d..abc6e37 100644
--- a/lib/lp/app/browser/doc/launchpad-search-pages.txt
+++ b/lib/lp/app/browser/doc/launchpad-search-pages.txt
@@ -39,11 +39,10 @@ When text is not None, the title indicates what was searched.
39 ... search_param_list = []39 ... search_param_list = []
40 ... for name in sorted(form):40 ... for name in sorted(form):
41 ... value = form[name]41 ... value = form[name]
42 ... if isinstance(value, six.text_type):42 ... search_param_list.append(
43 ... value = wsgi_native_string(value)43 ... wsgi_native_string(name) + wsgi_native_string('=') +
44 ... search_param_list.append(b'%s=%s' % (44 ... wsgi_native_string(value))
45 ... wsgi_native_string(name), value))45 ... query_string = wsgi_native_string('&').join(search_param_list)
46 ... query_string = b'&'.join(search_param_list)
47 ... request = LaunchpadTestRequest(46 ... request = LaunchpadTestRequest(
48 ... SERVER_URL='https://launchpad.test/+search',47 ... SERVER_URL='https://launchpad.test/+search',
49 ... QUERY_STRING=query_string, form=form, PATH_INFO='/+search')48 ... QUERY_STRING=query_string, form=form, PATH_INFO='/+search')
@@ -129,7 +128,7 @@ created because they are the owner.
129 ... owner=sample_person, information_type=InformationType.USERDATA)128 ... owner=sample_person, information_type=InformationType.USERDATA)
130129
131 >>> search_view = getSearchView(130 >>> search_view = getSearchView(
132 ... form={'field.text': private_bug.id})131 ... form={'field.text': str(private_bug.id)})
133 >>> search_view.bug.private132 >>> search_view.bug.private
134 True133 True
135134
@@ -137,7 +136,7 @@ But anonymous and unprivileged users cannot see the private bug.
137136
138 >>> login(ANONYMOUS)137 >>> login(ANONYMOUS)
139 >>> search_view = getSearchView(138 >>> search_view = getSearchView(
140 ... form={'field.text': private_bug.id})139 ... form={'field.text': str(private_bug.id)})
141 >>> print(search_view.bug)140 >>> print(search_view.bug)
142 None141 None
143142
diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
index 7c54063..9e4189c 100644
--- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
+++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
@@ -209,20 +209,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
209209
210 # Create fake UEFI keys for the root210 # Create fake UEFI keys for the root
211 for filename in ("uefi.key", "uefi.crt"):211 for filename in ("uefi.key", "uefi.crt"):
212 with open(os.path.join(archive_root, filename), 'wb') as fd:212 with open(os.path.join(archive_root, filename), 'w') as fd:
213 fd.write(b"Root %s" % filename)213 fd.write("Root %s" % filename)
214214
215 # Create fake OPAL and Kmod keys for series1215 # Create fake OPAL and Kmod keys for series1
216 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):216 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):
217 with open(os.path.join(key_dirs[series1], filename), 'wb') as fd:217 with open(os.path.join(key_dirs[series1], filename), 'w') as fd:
218 fd.write(b"Series 1 %s" % filename)218 fd.write("Series 1 %s" % filename)
219219
220 # Create fake FIT keys for series1220 # Create fake FIT keys for series1
221 os.makedirs(os.path.join(key_dirs[series1], "fit"))221 os.makedirs(os.path.join(key_dirs[series1], "fit"))
222 for filename in ("fit.key", "fit.crt"):222 for filename in ("fit.key", "fit.crt"):
223 with open(os.path.join(key_dirs[series1], "fit", filename),223 with open(os.path.join(key_dirs[series1], "fit", filename),
224 'wb') as fd:224 'w') as fd:
225 fd.write(b"Series 1 %s" % filename)225 fd.write("Series 1 %s" % filename)
226226
227 script = self.makeScript(["--archive", archive.reference])227 script = self.makeScript(["--archive", archive.reference])
228 script.inject = mock.Mock()228 script.inject = mock.Mock()
@@ -304,20 +304,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
304304
305 # Create fake UEFI keys for the root305 # Create fake UEFI keys for the root
306 for filename in ("uefi.key", "uefi.crt"):306 for filename in ("uefi.key", "uefi.crt"):
307 with open(os.path.join(archive_root, filename), 'wb') as fd:307 with open(os.path.join(archive_root, filename), 'w') as fd:
308 fd.write(b"Root %s" % filename)308 fd.write("Root %s" % filename)
309309
310 # Create fake OPAL and Kmod keys for series1310 # Create fake OPAL and Kmod keys for series1
311 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):311 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):
312 with open(os.path.join(key_dirs[series1], filename), 'wb') as fd:312 with open(os.path.join(key_dirs[series1], filename), 'w') as fd:
313 fd.write(b"Series 1 %s" % filename)313 fd.write("Series 1 %s" % filename)
314314
315 # Create fake FIT keys for series1315 # Create fake FIT keys for series1
316 os.makedirs(os.path.join(key_dirs[series1], "fit"))316 os.makedirs(os.path.join(key_dirs[series1], "fit"))
317 for filename in ("fit.key", "fit.crt"):317 for filename in ("fit.key", "fit.crt"):
318 with open(os.path.join(key_dirs[series1], "fit", filename),318 with open(os.path.join(key_dirs[series1], "fit", filename),
319 'wb') as fd:319 'w') as fd:
320 fd.write(b"Series 1 %s" % filename)320 fd.write("Series 1 %s" % filename)
321321
322 script = self.makeScript(322 script = self.makeScript(
323 ["--archive", archive.reference, "--overwrite", "--dry-run"])323 ["--archive", archive.reference, "--overwrite", "--dry-run"])
@@ -385,8 +385,8 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
385 gpgkey = self.factory.makeGPGKey(archive.owner)385 gpgkey = self.factory.makeGPGKey(archive.owner)
386 secret_key_path = os.path.join(386 secret_key_path = os.path.join(
387 self.signing_root_dir, "%s.gpg" % gpgkey.fingerprint)387 self.signing_root_dir, "%s.gpg" % gpgkey.fingerprint)
388 with open(secret_key_path, "wb") as fd:388 with open(secret_key_path, "w") as fd:
389 fd.write(b"Private key %s" % gpgkey.fingerprint)389 fd.write("Private key %s" % gpgkey.fingerprint)
390 archive.signing_key_owner = archive.owner390 archive.signing_key_owner = archive.owner
391 archive.signing_key_fingerprint = gpgkey.fingerprint391 archive.signing_key_fingerprint = gpgkey.fingerprint
392392
diff --git a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
index 1647a69..ba8dda6 100644
--- a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
+++ b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
@@ -66,10 +66,10 @@ The most common case will be that the user is sent to the guided
66 >>> filebug_path = (66 >>> filebug_path = (
67 ... '/ubuntu/+source/mozilla-firefox/+filebug/%s' % blob_token)67 ... '/ubuntu/+source/mozilla-firefox/+filebug/%s' % blob_token)
68 >>> filebug_url = 'http://%s%s' % (filebug_host, filebug_path)68 >>> filebug_url = 'http://%s%s' % (filebug_host, filebug_path)
69 >>> contents = str(http(69 >>> contents = str(http(six.ensure_binary(
70 ... b"GET %s HTTP/1.1\nHostname: %s\n"70 ... "GET %s HTTP/1.1\nHostname: %s\n"
71 ... b"Authorization: Basic test@canonical.com:test\n\n"71 ... "Authorization: Basic test@canonical.com:test\n\n"
72 ... % (filebug_path, filebug_host)))72 ... % (filebug_path, filebug_host))))
7373
74At first, the user will be shown a message telling them that the extra74At first, the user will be shown a message telling them that the extra
75data is being processed.75data is being processed.
diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
index 6fb0049..7e19f5b 100644
--- a/lib/lp/buildmaster/tests/mock_slaves.py
+++ b/lib/lp/buildmaster/tests/mock_slaves.py
@@ -217,7 +217,7 @@ class WaitingSlave(OkSlave):
217 if isinstance(file_to_write, six.string_types):217 if isinstance(file_to_write, six.string_types):
218 file_to_write = open(file_to_write, 'wb')218 file_to_write = open(file_to_write, 'wb')
219 if not self.valid_files[hash]:219 if not self.valid_files[hash]:
220 content = b"This is a %s" % hash220 content = ("This is a %s" % hash).encode("ASCII")
221 else:221 else:
222 with open(self.valid_files[hash], 'rb') as source:222 with open(self.valid_files[hash], 'rb') as source:
223 content = source.read()223 content = source.read()
diff --git a/lib/lp/services/daemons/tests/test_tachandler.py b/lib/lp/services/daemons/tests/test_tachandler.py
index 75d45a7..0b01898 100644
--- a/lib/lp/services/daemons/tests/test_tachandler.py
+++ b/lib/lp/services/daemons/tests/test_tachandler.py
@@ -169,7 +169,7 @@ class TacTestSetupTestCase(testtools.TestCase):
169 with open(fixture.logfile, "wb") as logfile:169 with open(fixture.logfile, "wb") as logfile:
170 logfile.write(b"One\n")170 logfile.write(b"One\n")
171 logfile.write(b"Two\n")171 logfile.write(b"Two\n")
172 logfile.write(b"Three, %s\n" % LOG_MAGIC.encode("UTF-8"))172 logfile.write(("Three, %s\n" % LOG_MAGIC).encode("UTF-8"))
173 logfile.write(b"Four\n")173 logfile.write(b"Four\n")
174174
175 # Truncating the log leaves everything up to and including the line175 # Truncating the log leaves everything up to and including the line
@@ -177,5 +177,5 @@ class TacTestSetupTestCase(testtools.TestCase):
177 fixture.truncateLog()177 fixture.truncateLog()
178 with open(fixture.logfile, "rb") as logfile:178 with open(fixture.logfile, "rb") as logfile:
179 self.assertEqual(179 self.assertEqual(
180 b"One\nTwo\nThree, %s\n" % LOG_MAGIC.encode("UTF-8"),180 ("One\nTwo\nThree, %s\n" % LOG_MAGIC).encode("UTF-8"),
181 logfile.read())181 logfile.read())
diff --git a/lib/lp/services/librarianserver/doc/upload.txt b/lib/lp/services/librarianserver/doc/upload.txt
index ca8c26a..595b0b7 100644
--- a/lib/lp/services/librarianserver/doc/upload.txt
+++ b/lib/lp/services/librarianserver/doc/upload.txt
@@ -108,13 +108,13 @@ Filename with spaces work.
108108
109Unicode filenames work, but must be encoded as UTF-8 on the socket.109Unicode filenames work, but must be encoded as UTF-8 on the socket.
110110
111 >>> filename = 'Yow\N{INTERROBANG}'.encode('utf-8')111 >>> filename = 'Yow\N{INTERROBANG}'
112 >>> upload_request(b"""STORE 14 %s112 >>> upload_request(("""STORE 14 %s
113 ... Content-Type: text/plain113 ... Content-Type: text/plain
114 ... File-Content-ID: 123114 ... File-Content-ID: 123
115 ... File-Alias-ID: 456115 ... File-Alias-ID: 456
116 ... Database-Name: right_database116 ... Database-Name: right_database
117 ...117 ...
118 ... Cats and dogs.""" % filename)118 ... Cats and dogs.""" % filename).encode('UTF-8'))
119 reply: '200'119 reply: '200'
120 file 'Yow‽' stored as text/plain, contents: 'Cats and dogs.'120 file 'Yow‽' stored as text/plain, contents: 'Cats and dogs.'
diff --git a/lib/lp/soyuz/scripts/tests/test_copypackage.py b/lib/lp/soyuz/scripts/tests/test_copypackage.py
index 8fdf14e..1bce73c 100644
--- a/lib/lp/soyuz/scripts/tests/test_copypackage.py
+++ b/lib/lp/soyuz/scripts/tests/test_copypackage.py
@@ -2068,9 +2068,9 @@ class TestCopyClosesBugs(TestCaseWithFactory):
20682068
2069 def createSource(self, version, archive, pocket, bug_id):2069 def createSource(self, version, archive, pocket, bug_id):
2070 changes_template = (2070 changes_template = (
2071 b"Format: 1.7\n"2071 "Format: 1.7\n"
2072 b"Launchpad-bugs-fixed: %s\n")2072 "Launchpad-bugs-fixed: %s\n")
2073 changes_file_content = changes_template % bug_id2073 changes_file_content = (changes_template % bug_id).encode("UTF-8")
2074 source = self.test_publisher.getPubSource(2074 source = self.test_publisher.getPubSource(
2075 sourcename='buggy-source', version=version,2075 sourcename='buggy-source', version=version,
2076 distroseries=self.hoary_test, archive=archive, pocket=pocket,2076 distroseries=self.hoary_test, archive=archive, pocket=pocket,
diff --git a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
index f4ad646..ca2e9a1 100644
--- a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
+++ b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
@@ -251,10 +251,10 @@ Sample Person can't access the file.
251251
252The 'No Privileges' user, the PPA owner, can download the DSC file.252The 'No Privileges' user, the PPA owner, can download the DSC file.
253253
254 >>> print(http(br"""254 >>> print(http(six.ensure_binary(r"""
255 ... GET %s HTTP/1.1255 ... GET %s HTTP/1.1
256 ... Authorization: Basic no-priv@canonical.com:test256 ... Authorization: Basic no-priv@canonical.com:test
257 ... """ % (dsc_file_lp_url.replace('http://launchpad.test', ''))))257 ... """ % (dsc_file_lp_url.replace('http://launchpad.test', '')))))
258 HTTP/1.1 303 See Other258 HTTP/1.1 303 See Other
259 ...259 ...
260 Location: https://...restricted.../test-pkg_1.0.dsc?token=...260 Location: https://...restricted.../test-pkg_1.0.dsc?token=...
@@ -272,10 +272,10 @@ Binary files are served via '+files' rather than '+sourcefiles'.
272 Traceback (most recent call last):272 Traceback (most recent call last):
273 ...273 ...
274 zope.security.interfaces.Unauthorized274 zope.security.interfaces.Unauthorized
275 >>> print(http(br"""275 >>> print(http(six.ensure_binary(r"""
276 ... GET %s HTTP/1.1276 ... GET %s HTTP/1.1
277 ... Authorization: Basic no-priv@canonical.com:test277 ... Authorization: Basic no-priv@canonical.com:test
278 ... """ % (deb_file_lp_url.replace('http://launchpad.test', ''))))278 ... """ % (deb_file_lp_url.replace('http://launchpad.test', '')))))
279 HTTP/1.1 303 See Other279 HTTP/1.1 303 See Other
280 ...280 ...
281 Location: https://...restricted.../test-bin_1.0_all.deb?token=...281 Location: https://...restricted.../test-bin_1.0_all.deb?token=...
@@ -314,9 +314,9 @@ binaries across to no-priv's public ppa.
314 >>> print(file_librarian_url)314 >>> print(file_librarian_url)
315 http://.../test-pkg_1.0.dsc315 http://.../test-pkg_1.0.dsc
316316
317 >>> print(http(br"""317 >>> print(http(six.ensure_binary(r"""
318 ... GET %s HTTP/1.1318 ... GET %s HTTP/1.1
319 ... """ % file_lp_url.replace('http://launchpad.test', '')))319 ... """ % file_lp_url.replace('http://launchpad.test', ''))))
320 HTTP/1.1 303 See Other320 HTTP/1.1 303 See Other
321 ...321 ...
322 Location: http://.../test-pkg_1.0.dsc322 Location: http://.../test-pkg_1.0.dsc
@@ -341,10 +341,10 @@ redirect to the files for the default named PPA.
341 >>> file_lp_url_without_ppa_name = (341 >>> file_lp_url_without_ppa_name = (
342 ... 'http://launchpad.test/~no-priv/+archive/+files/test-pkg_1.0.dsc')342 ... 'http://launchpad.test/~no-priv/+archive/+files/test-pkg_1.0.dsc')
343343
344 >>> print(http(br"""344 >>> print(http(six.ensure_binary(r"""
345 ... GET %s HTTP/1.1345 ... GET %s HTTP/1.1
346 ... """ % file_lp_url_without_ppa_name.replace(346 ... """ % file_lp_url_without_ppa_name.replace(
347 ... 'http://launchpad.test', '')))347 ... 'http://launchpad.test', ''))))
348 HTTP/1.1 301 Moved Permanently348 HTTP/1.1 301 Moved Permanently
349 ...349 ...
350 Location: http://localhost/~no-priv/+archive/ubuntu/ppa/+files/test-pkg_1.0.dsc350 Location: http://localhost/~no-priv/+archive/ubuntu/ppa/+files/test-pkg_1.0.dsc
@@ -354,10 +354,10 @@ The same redirection happens for +archive/+build/blah urls:
354354
355 >>> buildlog_lp_url_without_ppa_name = (355 >>> buildlog_lp_url_without_ppa_name = (
356 ... 'http://launchpad.test/~no-priv/+archive/+build/1/+files/foo')356 ... 'http://launchpad.test/~no-priv/+archive/+build/1/+files/foo')
357 >>> print(http(br"""357 >>> print(http(six.ensure_binary(r"""
358 ... GET %s HTTP/1.1358 ... GET %s HTTP/1.1
359 ... """ % buildlog_lp_url_without_ppa_name.replace(359 ... """ % buildlog_lp_url_without_ppa_name.replace(
360 ... 'http://launchpad.test', '')))360 ... 'http://launchpad.test', ''))))
361 HTTP/1.1 301 Moved Permanently361 HTTP/1.1 301 Moved Permanently
362 ...362 ...
363 Location: http://.../~no-priv/+archive/ubuntu/ppa/+build/1/+files/...363 Location: http://.../~no-priv/+archive/ubuntu/ppa/+build/1/+files/...
@@ -411,9 +411,9 @@ LP proxy URL a proper NotFound error is raised.
411 >>> print(file_lp_url)411 >>> print(file_lp_url)
412 http://launchpad.test/~no-priv/+archive/ubuntu/ppa/+sourcefiles/test-pkg/1.0/test-pkg_1.0.dsc412 http://launchpad.test/~no-priv/+archive/ubuntu/ppa/+sourcefiles/test-pkg/1.0/test-pkg_1.0.dsc
413413
414 >>> not_found_file = http(br"""414 >>> not_found_file = http(six.ensure_binary(r"""
415 ... GET %s HTTP/1.1415 ... GET %s HTTP/1.1
416 ... """ % file_lp_url.replace('http://launchpad.test', ''))416 ... """ % file_lp_url.replace('http://launchpad.test', '')))
417417
418It results in a 404 response.418It results in a 404 response.
419419
diff --git a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
index b49a677..d9a96cc 100644
--- a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
+++ b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
@@ -62,7 +62,7 @@ We create the POFile object where we are going to attach the .po file.
6262
63First, we do a valid import.63First, we do a valid import.
6464
65 >>> pofile_contents = br'''65 >>> pofile_contents = six.ensure_binary(r'''
66 ... msgid ""66 ... msgid ""
67 ... msgstr ""67 ... msgstr ""
68 ... "PO-Revision-Date: 2005-05-03 20:41+0100\n"68 ... "PO-Revision-Date: 2005-05-03 20:41+0100\n"
@@ -74,7 +74,7 @@ First, we do a valid import.
74 ...74 ...
75 ... msgid "foo"75 ... msgid "foo"
76 ... msgstr "blah"76 ... msgstr "blah"
77 ... ''' % datetime.datetime.now(UTC).isoformat()77 ... ''' % datetime.datetime.now(UTC).isoformat())
78 >>> by_maintainer = False78 >>> by_maintainer = False
79 >>> entry = translation_import_queue.addOrUpdateEntry(79 >>> entry = translation_import_queue.addOrUpdateEntry(
80 ... pofile.path, pofile_contents, by_maintainer, person,80 ... pofile.path, pofile_contents, by_maintainer, person,
@@ -110,7 +110,7 @@ file we just imported.
110Now, we are going to import a .po file that has a 'PO-Revision-Date'110Now, we are going to import a .po file that has a 'PO-Revision-Date'
111field with a date older than a previous .po import.111field with a date older than a previous .po import.
112112
113 >>> pofile_contents = br'''113 >>> pofile_contents = six.ensure_binary(r'''
114 ... msgid ""114 ... msgid ""
115 ... msgstr ""115 ... msgstr ""
116 ... "PO-Revision-Date: 2005-05-03 19:41+0100\n"116 ... "PO-Revision-Date: 2005-05-03 19:41+0100\n"
@@ -122,7 +122,7 @@ field with a date older than a previous .po import.
122 ...122 ...
123 ... msgid "foo"123 ... msgid "foo"
124 ... msgstr "blah"124 ... msgstr "blah"
125 ... ''' % datetime.datetime.now(UTC).isoformat()125 ... ''' % datetime.datetime.now(UTC).isoformat())
126 >>> by_maintainer = False126 >>> by_maintainer = False
127 >>> entry = translation_import_queue.addOrUpdateEntry(127 >>> entry = translation_import_queue.addOrUpdateEntry(
128 ... pofile.path, pofile_contents, by_maintainer, person,128 ... pofile.path, pofile_contents, by_maintainer, person,
diff --git a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
index 44ce5f5..bc89865 100644
--- a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
+++ b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
@@ -58,7 +58,7 @@ We create the POFile object where we are going to attach the .po file.
58Let's import a .po file that misses the '"' char after msgstr. That's a58Let's import a .po file that misses the '"' char after msgstr. That's a
59syntax error.59syntax error.
6060
61 >>> pofile_contents = br'''61 >>> pofile_contents = six.ensure_binary(r'''
62 ... msgid ""62 ... msgid ""
63 ... msgstr ""63 ... msgstr ""
64 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"64 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"
@@ -70,7 +70,7 @@ syntax error.
70 ... 70 ...
71 ... msgid "foo"71 ... msgid "foo"
72 ... msgstr blah"72 ... msgstr blah"
73 ... ''' % datetime.datetime.now(UTC).isoformat()73 ... ''' % datetime.datetime.now(UTC).isoformat())
74 >>> by_maintainer = False74 >>> by_maintainer = False
75 >>> entry = translation_import_queue.addOrUpdateEntry(75 >>> entry = translation_import_queue.addOrUpdateEntry(
76 ... pofile.path, pofile_contents, by_maintainer, person,76 ... pofile.path, pofile_contents, by_maintainer, person,
@@ -194,7 +194,7 @@ In his rush to be the first Sumerian translator for Firefox, Mark
194submits a translation with a nonsensical plurals definition.194submits a translation with a nonsensical plurals definition.
195195
196 >>> pofile = potemplate.newPOFile('sux')196 >>> pofile = potemplate.newPOFile('sux')
197 >>> pofile_contents = br'''197 >>> pofile_contents = six.ensure_binary(r'''
198 ... msgid ""198 ... msgid ""
199 ... msgstr ""199 ... msgstr ""
200 ... "PO-Revision-Date: 2005-06-29 11:44+0100\n"200 ... "PO-Revision-Date: 2005-06-29 11:44+0100\n"
@@ -205,7 +205,7 @@ submits a translation with a nonsensical plurals definition.
205 ... 205 ...
206 ... msgid "foo"206 ... msgid "foo"
207 ... msgstr "bar"207 ... msgstr "bar"
208 ... ''' % datetime.datetime.now(UTC).isoformat()208 ... ''' % datetime.datetime.now(UTC).isoformat())
209 >>> entry = translation_import_queue.addOrUpdateEntry(209 >>> entry = translation_import_queue.addOrUpdateEntry(
210 ... pofile.path, pofile_contents, False, person,210 ... pofile.path, pofile_contents, False, person,
211 ... productseries=series, potemplate=potemplate, pofile=pofile)211 ... productseries=series, potemplate=potemplate, pofile=pofile)
@@ -238,7 +238,7 @@ Not enough forms
238Mark mistakenly attempts to import a translation with "zero" plural238Mark mistakenly attempts to import a translation with "zero" plural
239forms. He receives an email notifying him of a syntax error.239forms. He receives an email notifying him of a syntax error.
240240
241 >>> pofile_contents = br'''241 >>> pofile_contents = six.ensure_binary(r'''
242 ... msgid ""242 ... msgid ""
243 ... msgstr ""243 ... msgstr ""
244 ... "PO-Revision-Date: 2005-06-14 18:33+0100\n"244 ... "PO-Revision-Date: 2005-06-14 18:33+0100\n"
@@ -249,7 +249,7 @@ forms. He receives an email notifying him of a syntax error.
249 ... 249 ...
250 ... msgid "foo"250 ... msgid "foo"
251 ... msgstr "bar"251 ... msgstr "bar"
252 ... ''' % datetime.datetime.now(UTC).isoformat()252 ... ''' % datetime.datetime.now(UTC).isoformat())
253 >>> entry = translation_import_queue.addOrUpdateEntry(253 >>> entry = translation_import_queue.addOrUpdateEntry(
254 ... pofile.path, pofile_contents, False, person,254 ... pofile.path, pofile_contents, False, person,
255 ... productseries=series, potemplate=potemplate, pofile=pofile)255 ... productseries=series, potemplate=potemplate, pofile=pofile)
@@ -276,7 +276,7 @@ forms. He receives an email notifying him of a syntax error.
276On his next attempt, Mark accidentally types a negative number of plural276On his next attempt, Mark accidentally types a negative number of plural
277forms. The same error is given.277forms. The same error is given.
278278
279 >>> pofile_contents = br'''279 >>> pofile_contents = six.ensure_binary(r'''
280 ... msgid ""280 ... msgid ""
281 ... msgstr ""281 ... msgstr ""
282 ... "PO-Revision-Date: 2005-06-15 19:04+0100\n"282 ... "PO-Revision-Date: 2005-06-15 19:04+0100\n"
@@ -287,7 +287,7 @@ forms. The same error is given.
287 ... 287 ...
288 ... msgid "foo"288 ... msgid "foo"
289 ... msgstr "bar"289 ... msgstr "bar"
290 ... ''' % datetime.datetime.now(UTC).isoformat()290 ... ''' % datetime.datetime.now(UTC).isoformat())
291 >>> entry = translation_import_queue.addOrUpdateEntry(291 >>> entry = translation_import_queue.addOrUpdateEntry(
292 ... pofile.path, pofile_contents, False, person,292 ... pofile.path, pofile_contents, False, person,
293 ... productseries=series, potemplate=potemplate, pofile=pofile)293 ... productseries=series, potemplate=potemplate, pofile=pofile)
@@ -325,7 +325,7 @@ to get that information corrected if need be.
325 >>> pofile = potemplate.newPOFile('ar')325 >>> pofile = potemplate.newPOFile('ar')
326326
327 # PO file with nplurals=7, a value we can't handle.327 # PO file with nplurals=7, a value we can't handle.
328 >>> pofile_contents = br'''328 >>> pofile_contents = six.ensure_binary(r'''
329 ... msgid ""329 ... msgid ""
330 ... msgstr ""330 ... msgstr ""
331 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"331 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"
@@ -343,7 +343,7 @@ to get that information corrected if need be.
343 ... msgstr[4] "baros %%d"343 ... msgstr[4] "baros %%d"
344 ... msgstr[5] "barorum %%d"344 ... msgstr[5] "barorum %%d"
345 ... msgstr[6] "barim %%d"345 ... msgstr[6] "barim %%d"
346 ... ''' % datetime.datetime.now(UTC).isoformat()346 ... ''' % datetime.datetime.now(UTC).isoformat())
347 >>> entry = translation_import_queue.addOrUpdateEntry(347 >>> entry = translation_import_queue.addOrUpdateEntry(
348 ... pofile.path, pofile_contents, False, person,348 ... pofile.path, pofile_contents, False, person,
349 ... productseries=series, potemplate=potemplate, pofile=pofile)349 ... productseries=series, potemplate=potemplate, pofile=pofile)
@@ -389,7 +389,7 @@ Once Mark has checked the language page and corrected the number of
389plural forms, the file imports just fine.389plural forms, the file imports just fine.
390390
391 # Same PO file as before, but with nplurals=6.391 # Same PO file as before, but with nplurals=6.
392 >>> pofile_contents = br'''392 >>> pofile_contents = six.ensure_binary(r'''
393 ... msgid ""393 ... msgid ""
394 ... msgstr ""394 ... msgstr ""
395 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"395 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"
@@ -406,7 +406,7 @@ plural forms, the file imports just fine.
406 ... msgstr[3] "baribus %%d"406 ... msgstr[3] "baribus %%d"
407 ... msgstr[4] "baros %%d"407 ... msgstr[4] "baros %%d"
408 ... msgstr[5] "barorum %%d"408 ... msgstr[5] "barorum %%d"
409 ... ''' % datetime.datetime.now(UTC).isoformat()409 ... ''' % datetime.datetime.now(UTC).isoformat())
410 >>> entry = translation_import_queue.addOrUpdateEntry(410 >>> entry = translation_import_queue.addOrUpdateEntry(
411 ... pofile.path, pofile_contents, False, person,411 ... pofile.path, pofile_contents, False, person,
412 ... productseries=series, potemplate=potemplate, pofile=pofile)412 ... productseries=series, potemplate=potemplate, pofile=pofile)
diff --git a/lib/lp/translations/doc/poimport.txt b/lib/lp/translations/doc/poimport.txt
index 1c49a97..5b07995 100644
--- a/lib/lp/translations/doc/poimport.txt
+++ b/lib/lp/translations/doc/poimport.txt
@@ -56,7 +56,7 @@ And this is the POTemplate where the import will be done.
5656
57This is the file that'll get imported.57This is the file that'll get imported.
5858
59 >>> potemplate_contents = br'''59 >>> potemplate_contents = six.ensure_binary(r'''
60 ... msgid ""60 ... msgid ""
61 ... msgstr ""61 ... msgstr ""
62 ... "POT-Creation-Date: 2004-07-11 16:16+0900\n"62 ... "POT-Creation-Date: 2004-07-11 16:16+0900\n"
@@ -86,7 +86,7 @@ This is the file that'll get imported.
86 ...86 ...
87 ... msgid "translator-credits"87 ... msgid "translator-credits"
88 ... msgstr ""88 ... msgstr ""
89 ... ''' % datetime.datetime.now(UTC).isoformat()89 ... ''' % datetime.datetime.now(UTC).isoformat())
9090
91We sometimes saw deadlocks as POFile statistics were updated after91We sometimes saw deadlocks as POFile statistics were updated after
92importing a template. The operation would read all translation messages92importing a template. The operation would read all translation messages
@@ -226,7 +226,7 @@ Import With Errors
226Here are the contents of the file we'll be importing. It has some226Here are the contents of the file we'll be importing. It has some
227validation errors.227validation errors.
228228
229 >>> pofile_with_errors = br'''229 >>> pofile_with_errors = six.ensure_binary(r'''
230 ... msgid ""230 ... msgid ""
231 ... msgstr ""231 ... msgstr ""
232 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"232 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"
@@ -257,7 +257,7 @@ validation errors.
257 ... msgstr[1] "Bars %%d"257 ... msgstr[1] "Bars %%d"
258 ... msgstr[2] "Welsh power! %%d"258 ... msgstr[2] "Welsh power! %%d"
259 ... msgstr[3] "We have four! %%d"259 ... msgstr[3] "We have four! %%d"
260 ... ''' % datetime.datetime.now(UTC).isoformat()260 ... ''' % datetime.datetime.now(UTC).isoformat())
261261
262This is the dbschema that controls the validation of a translation.262This is the dbschema that controls the validation of a translation.
263263
@@ -423,7 +423,7 @@ instance) and they don't mean that any messages failed to import.
423423
424For example, here's a gettext PO file with two headers.424For example, here's a gettext PO file with two headers.
425425
426 >>> pofile_with_warning = br'''426 >>> pofile_with_warning = six.ensure_binary(r'''
427 ... msgid ""427 ... msgid ""
428 ... msgstr ""428 ... msgstr ""
429 ... "Content-Type: text/plain; charset=UTF-8\n"429 ... "Content-Type: text/plain; charset=UTF-8\n"
@@ -439,7 +439,7 @@ For example, here's a gettext PO file with two headers.
439 ...439 ...
440 ... msgid "a"440 ... msgid "a"
441 ... msgstr "b"441 ... msgstr "b"
442 ... ''' % datetime.datetime.now(UTC).isoformat()442 ... ''' % datetime.datetime.now(UTC).isoformat())
443 >>> eo_pofile = potemplate.newPOFile('eo')443 >>> eo_pofile = potemplate.newPOFile('eo')
444 >>> warning_entry = translation_import_queue.addOrUpdateEntry(444 >>> warning_entry = translation_import_queue.addOrUpdateEntry(
445 ... 'eo.po', pofile_with_warning, False, potemplate.owner,445 ... 'eo.po', pofile_with_warning, False, potemplate.owner,
@@ -484,7 +484,7 @@ Import Without Errors
484Now, let's import one without errors. This file changes one translation484Now, let's import one without errors. This file changes one translation
485and adds another one.485and adds another one.
486486
487 >>> pofile_without_errors = br'''487 >>> pofile_without_errors = six.ensure_binary(r'''
488 ... msgid ""488 ... msgid ""
489 ... msgstr ""489 ... msgstr ""
490 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"490 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"
@@ -502,7 +502,7 @@ and adds another one.
502 ...502 ...
503 ... msgid "translator-credits"503 ... msgid "translator-credits"
504 ... msgstr "helpful@example.com"504 ... msgstr "helpful@example.com"
505 ... ''' % datetime.datetime.now(UTC).isoformat()505 ... ''' % datetime.datetime.now(UTC).isoformat())
506 >>> entry = translation_import_queue.addOrUpdateEntry(506 >>> entry = translation_import_queue.addOrUpdateEntry(
507 ... pofile.path, pofile_without_errors, True, rosetta_experts,507 ... pofile.path, pofile_without_errors, True, rosetta_experts,
508 ... distroseries=distroseries, sourcepackagename=sourcepackagename,508 ... distroseries=distroseries, sourcepackagename=sourcepackagename,
@@ -645,7 +645,7 @@ plural forms).
645645
646We'll import a POFile with 3 plural forms into this POFile:646We'll import a POFile with 3 plural forms into this POFile:
647647
648 >>> pofile_with_plurals = br'''648 >>> pofile_with_plurals = six.ensure_binary(r'''
649 ... msgid ""649 ... msgid ""
650 ... msgstr ""650 ... msgstr ""
651 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"651 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"
@@ -660,7 +660,7 @@ We'll import a POFile with 3 plural forms into this POFile:
660 ... msgstr[0] "First form %%d"660 ... msgstr[0] "First form %%d"
661 ... msgstr[1] "Second form %%d"661 ... msgstr[1] "Second form %%d"
662 ... msgstr[2] "Third form %%d"662 ... msgstr[2] "Third form %%d"
663 ... ''' % datetime.datetime.now(UTC).isoformat()663 ... ''' % datetime.datetime.now(UTC).isoformat())
664664
665We now import this POFile as this language's translation for the soure665We now import this POFile as this language's translation for the soure
666package:666package:
diff --git a/lib/lp/translations/doc/rosetta-karma.txt b/lib/lp/translations/doc/rosetta-karma.txt
index f5bda21..caad946 100644
--- a/lib/lp/translations/doc/rosetta-karma.txt
+++ b/lib/lp/translations/doc/rosetta-karma.txt
@@ -121,7 +121,7 @@ Let's say that we have this .po file to import:
121 >>> import datetime121 >>> import datetime
122 >>> import pytz122 >>> import pytz
123 >>> UTC = pytz.timezone('UTC')123 >>> UTC = pytz.timezone('UTC')
124 >>> pofile_contents = br'''124 >>> pofile_contents = six.ensure_binary(r'''
125 ... msgid ""125 ... msgid ""
126 ... msgstr ""126 ... msgstr ""
127 ... "Content-Type: text/plain; charset=UTF-8\n"127 ... "Content-Type: text/plain; charset=UTF-8\n"
@@ -129,7 +129,7 @@ Let's say that we have this .po file to import:
129 ...129 ...
130 ... msgid "foo"130 ... msgid "foo"
131 ... msgstr "bar"131 ... msgstr "bar"
132 ... ''' % datetime.datetime.now(UTC).isoformat()132 ... ''' % datetime.datetime.now(UTC).isoformat())
133 >>> potemplate = POTemplate.get(1)133 >>> potemplate = POTemplate.get(1)
134 >>> pofile = potemplate.getPOFileByLang('es')134 >>> pofile = potemplate.getPOFileByLang('es')
135135
@@ -193,7 +193,7 @@ Tell the PO file to import from the file data it has.
193Now, the user is going to upload a local edition of the .po file. In this193Now, the user is going to upload a local edition of the .po file. In this
194case, we will give karma *only* because the translation change.194case, we will give karma *only* because the translation change.
195195
196 >>> pofile_contents = br'''196 >>> pofile_contents = six.ensure_binary(r'''
197 ... msgid ""197 ... msgid ""
198 ... msgstr ""198 ... msgstr ""
199 ... "Content-Type: text/plain; charset=UTF-8\n"199 ... "Content-Type: text/plain; charset=UTF-8\n"
@@ -201,7 +201,7 @@ case, we will give karma *only* because the translation change.
201 ...201 ...
202 ... msgid "foo"202 ... msgid "foo"
203 ... msgstr "bars"203 ... msgstr "bars"
204 ... ''' % datetime.datetime.now(UTC).isoformat()204 ... ''' % datetime.datetime.now(UTC).isoformat())
205205
206We attach the new file as not comming from upstream.206We attach the new file as not comming from upstream.
207207
diff --git a/lib/lp/translations/doc/rosetta-poimport-script.txt b/lib/lp/translations/doc/rosetta-poimport-script.txt
index 8866db1..680c6a5 100644
--- a/lib/lp/translations/doc/rosetta-poimport-script.txt
+++ b/lib/lp/translations/doc/rosetta-poimport-script.txt
@@ -32,17 +32,17 @@ the sampledata.
32 None32 None
3333
34 >>> pofile = potemplate.newPOFile('sr')34 >>> pofile = potemplate.newPOFile('sr')
35 >>> pofile_content = br'''35 >>> pofile_content = six.ensure_binary('''
36 ... msgid ""36 ... msgid ""
37 ... msgstr ""37 ... msgstr ""
38 ... "PO-Revision-Date: 2005-06-04 20:41+0100\n"38 ... "PO-Revision-Date: 2005-06-04 20:41+0100\\n"
39 ... "Last-Translator: Danilo Šegan <danilo@canonical.com>\n"39 ... "Last-Translator: Danilo \u0160egan <danilo@canonical.com>\\n"
40 ... "Content-Type: text/plain; charset=UTF-8\n"40 ... "Content-Type: text/plain; charset=UTF-8\\n"
41 ... "X-Rosetta-Export-Date: %s\n"41 ... "X-Rosetta-Export-Date: %s\\n"
42 ...42 ...
43 ... msgid "Foo %%s"43 ... msgid "Foo %%s"
44 ... msgstr "Bar"44 ... msgstr "Bar"
45 ... ''' % datetime.datetime.now(UTC).isoformat()45 ... ''' % datetime.datetime.now(UTC).isoformat())
4646
47We clean the import queue.47We clean the import queue.
4848
diff --git a/lib/lp/translations/utilities/tests/test_translation_importer.py b/lib/lp/translations/utilities/tests/test_translation_importer.py
index 106ca2d..624b84b 100644
--- a/lib/lp/translations/utilities/tests/test_translation_importer.py
+++ b/lib/lp/translations/utilities/tests/test_translation_importer.py
@@ -235,7 +235,7 @@ class TranslationImporterTestCase(TestCaseWithFactory):
235 existing_translation = self.factory.makeCurrentTranslationMessage(235 existing_translation = self.factory.makeCurrentTranslationMessage(
236 pofile=pofile, potmsgset=potmsgset1)236 pofile=pofile, potmsgset=potmsgset1)
237237
238 text = b"""238 text = six.ensure_binary("""
239 msgid ""239 msgid ""
240 msgstr ""240 msgstr ""
241 "MIME-Version: 1.0\\n"241 "MIME-Version: 1.0\\n"
@@ -245,7 +245,7 @@ class TranslationImporterTestCase(TestCaseWithFactory):
245245
246 msgid "%s"246 msgid "%s"
247 msgstr "A translation."247 msgstr "A translation."
248 """ % potmsgset2.msgid_singular.msgid248 """ % potmsgset2.msgid_singular.msgid)
249249
250 entry = self.factory.makeTranslationImportQueueEntry(250 entry = self.factory.makeTranslationImportQueueEntry(
251 'foo.po', potemplate=template, pofile=pofile,251 'foo.po', potemplate=template, pofile=pofile,

Subscribers

People subscribed via source and target branches

to status/vote changes: