Merge ~cjwatson/launchpad:py3-bytes-formatting into launchpad:master
- Git
- lp:~cjwatson/launchpad
- py3-bytes-formatting
- Merge into 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) |
Related bugs: |
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.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/app/browser/doc/launchpad-search-pages.txt b/lib/lp/app/browser/doc/launchpad-search-pages.txt | |||
2 | index ded7f0d..abc6e37 100644 | |||
3 | --- a/lib/lp/app/browser/doc/launchpad-search-pages.txt | |||
4 | +++ b/lib/lp/app/browser/doc/launchpad-search-pages.txt | |||
5 | @@ -39,11 +39,10 @@ When text is not None, the title indicates what was searched. | |||
6 | 39 | ... search_param_list = [] | 39 | ... search_param_list = [] |
7 | 40 | ... for name in sorted(form): | 40 | ... for name in sorted(form): |
8 | 41 | ... value = form[name] | 41 | ... value = form[name] |
14 | 42 | ... if isinstance(value, six.text_type): | 42 | ... search_param_list.append( |
15 | 43 | ... value = wsgi_native_string(value) | 43 | ... wsgi_native_string(name) + wsgi_native_string('=') + |
16 | 44 | ... search_param_list.append(b'%s=%s' % ( | 44 | ... wsgi_native_string(value)) |
17 | 45 | ... wsgi_native_string(name), value)) | 45 | ... query_string = wsgi_native_string('&').join(search_param_list) |
13 | 46 | ... query_string = b'&'.join(search_param_list) | ||
18 | 47 | ... request = LaunchpadTestRequest( | 46 | ... request = LaunchpadTestRequest( |
19 | 48 | ... SERVER_URL='https://launchpad.test/+search', | 47 | ... SERVER_URL='https://launchpad.test/+search', |
20 | 49 | ... QUERY_STRING=query_string, form=form, PATH_INFO='/+search') | 48 | ... QUERY_STRING=query_string, form=form, PATH_INFO='/+search') |
21 | @@ -129,7 +128,7 @@ created because they are the owner. | |||
22 | 129 | ... owner=sample_person, information_type=InformationType.USERDATA) | 128 | ... owner=sample_person, information_type=InformationType.USERDATA) |
23 | 130 | 129 | ||
24 | 131 | >>> search_view = getSearchView( | 130 | >>> search_view = getSearchView( |
26 | 132 | ... form={'field.text': private_bug.id}) | 131 | ... form={'field.text': str(private_bug.id)}) |
27 | 133 | >>> search_view.bug.private | 132 | >>> search_view.bug.private |
28 | 134 | True | 133 | True |
29 | 135 | 134 | ||
30 | @@ -137,7 +136,7 @@ But anonymous and unprivileged users cannot see the private bug. | |||
31 | 137 | 136 | ||
32 | 138 | >>> login(ANONYMOUS) | 137 | >>> login(ANONYMOUS) |
33 | 139 | >>> search_view = getSearchView( | 138 | >>> search_view = getSearchView( |
35 | 140 | ... form={'field.text': private_bug.id}) | 139 | ... form={'field.text': str(private_bug.id)}) |
36 | 141 | >>> print(search_view.bug) | 140 | >>> print(search_view.bug) |
37 | 142 | None | 141 | None |
38 | 143 | 142 | ||
39 | diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py | |||
40 | index 7c54063..9e4189c 100644 | |||
41 | --- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py | |||
42 | +++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py | |||
43 | @@ -209,20 +209,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory): | |||
44 | 209 | 209 | ||
45 | 210 | # Create fake UEFI keys for the root | 210 | # Create fake UEFI keys for the root |
46 | 211 | for filename in ("uefi.key", "uefi.crt"): | 211 | for filename in ("uefi.key", "uefi.crt"): |
49 | 212 | with open(os.path.join(archive_root, filename), 'wb') as fd: | 212 | with open(os.path.join(archive_root, filename), 'w') as fd: |
50 | 213 | fd.write(b"Root %s" % filename) | 213 | fd.write("Root %s" % filename) |
51 | 214 | 214 | ||
52 | 215 | # Create fake OPAL and Kmod keys for series1 | 215 | # Create fake OPAL and Kmod keys for series1 |
53 | 216 | for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"): | 216 | for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"): |
56 | 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: |
57 | 218 | fd.write(b"Series 1 %s" % filename) | 218 | fd.write("Series 1 %s" % filename) |
58 | 219 | 219 | ||
59 | 220 | # Create fake FIT keys for series1 | 220 | # Create fake FIT keys for series1 |
60 | 221 | os.makedirs(os.path.join(key_dirs[series1], "fit")) | 221 | os.makedirs(os.path.join(key_dirs[series1], "fit")) |
61 | 222 | for filename in ("fit.key", "fit.crt"): | 222 | for filename in ("fit.key", "fit.crt"): |
62 | 223 | with open(os.path.join(key_dirs[series1], "fit", filename), | 223 | with open(os.path.join(key_dirs[series1], "fit", filename), |
65 | 224 | 'wb') as fd: | 224 | 'w') as fd: |
66 | 225 | fd.write(b"Series 1 %s" % filename) | 225 | fd.write("Series 1 %s" % filename) |
67 | 226 | 226 | ||
68 | 227 | script = self.makeScript(["--archive", archive.reference]) | 227 | script = self.makeScript(["--archive", archive.reference]) |
69 | 228 | script.inject = mock.Mock() | 228 | script.inject = mock.Mock() |
70 | @@ -304,20 +304,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory): | |||
71 | 304 | 304 | ||
72 | 305 | # Create fake UEFI keys for the root | 305 | # Create fake UEFI keys for the root |
73 | 306 | for filename in ("uefi.key", "uefi.crt"): | 306 | for filename in ("uefi.key", "uefi.crt"): |
76 | 307 | with open(os.path.join(archive_root, filename), 'wb') as fd: | 307 | with open(os.path.join(archive_root, filename), 'w') as fd: |
77 | 308 | fd.write(b"Root %s" % filename) | 308 | fd.write("Root %s" % filename) |
78 | 309 | 309 | ||
79 | 310 | # Create fake OPAL and Kmod keys for series1 | 310 | # Create fake OPAL and Kmod keys for series1 |
80 | 311 | for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"): | 311 | for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"): |
83 | 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: |
84 | 313 | fd.write(b"Series 1 %s" % filename) | 313 | fd.write("Series 1 %s" % filename) |
85 | 314 | 314 | ||
86 | 315 | # Create fake FIT keys for series1 | 315 | # Create fake FIT keys for series1 |
87 | 316 | os.makedirs(os.path.join(key_dirs[series1], "fit")) | 316 | os.makedirs(os.path.join(key_dirs[series1], "fit")) |
88 | 317 | for filename in ("fit.key", "fit.crt"): | 317 | for filename in ("fit.key", "fit.crt"): |
89 | 318 | with open(os.path.join(key_dirs[series1], "fit", filename), | 318 | with open(os.path.join(key_dirs[series1], "fit", filename), |
92 | 319 | 'wb') as fd: | 319 | 'w') as fd: |
93 | 320 | fd.write(b"Series 1 %s" % filename) | 320 | fd.write("Series 1 %s" % filename) |
94 | 321 | 321 | ||
95 | 322 | script = self.makeScript( | 322 | script = self.makeScript( |
96 | 323 | ["--archive", archive.reference, "--overwrite", "--dry-run"]) | 323 | ["--archive", archive.reference, "--overwrite", "--dry-run"]) |
97 | @@ -385,8 +385,8 @@ class TestSyncSigningKeysScript(TestCaseWithFactory): | |||
98 | 385 | gpgkey = self.factory.makeGPGKey(archive.owner) | 385 | gpgkey = self.factory.makeGPGKey(archive.owner) |
99 | 386 | secret_key_path = os.path.join( | 386 | secret_key_path = os.path.join( |
100 | 387 | self.signing_root_dir, "%s.gpg" % gpgkey.fingerprint) | 387 | self.signing_root_dir, "%s.gpg" % gpgkey.fingerprint) |
103 | 388 | with open(secret_key_path, "wb") as fd: | 388 | with open(secret_key_path, "w") as fd: |
104 | 389 | fd.write(b"Private key %s" % gpgkey.fingerprint) | 389 | fd.write("Private key %s" % gpgkey.fingerprint) |
105 | 390 | archive.signing_key_owner = archive.owner | 390 | archive.signing_key_owner = archive.owner |
106 | 391 | archive.signing_key_fingerprint = gpgkey.fingerprint | 391 | archive.signing_key_fingerprint = gpgkey.fingerprint |
107 | 392 | 392 | ||
108 | 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 | |||
109 | index 1647a69..ba8dda6 100644 | |||
110 | --- a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt | |||
111 | +++ b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt | |||
112 | @@ -66,10 +66,10 @@ The most common case will be that the user is sent to the guided | |||
113 | 66 | >>> filebug_path = ( | 66 | >>> filebug_path = ( |
114 | 67 | ... '/ubuntu/+source/mozilla-firefox/+filebug/%s' % blob_token) | 67 | ... '/ubuntu/+source/mozilla-firefox/+filebug/%s' % blob_token) |
115 | 68 | >>> filebug_url = 'http://%s%s' % (filebug_host, filebug_path) | 68 | >>> filebug_url = 'http://%s%s' % (filebug_host, filebug_path) |
120 | 69 | >>> contents = str(http( | 69 | >>> contents = str(http(six.ensure_binary( |
121 | 70 | ... b"GET %s HTTP/1.1\nHostname: %s\n" | 70 | ... "GET %s HTTP/1.1\nHostname: %s\n" |
122 | 71 | ... b"Authorization: Basic test@canonical.com:test\n\n" | 71 | ... "Authorization: Basic test@canonical.com:test\n\n" |
123 | 72 | ... % (filebug_path, filebug_host))) | 72 | ... % (filebug_path, filebug_host)))) |
124 | 73 | 73 | ||
125 | 74 | At first, the user will be shown a message telling them that the extra | 74 | At first, the user will be shown a message telling them that the extra |
126 | 75 | data is being processed. | 75 | data is being processed. |
127 | diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py | |||
128 | index 6fb0049..7e19f5b 100644 | |||
129 | --- a/lib/lp/buildmaster/tests/mock_slaves.py | |||
130 | +++ b/lib/lp/buildmaster/tests/mock_slaves.py | |||
131 | @@ -217,7 +217,7 @@ class WaitingSlave(OkSlave): | |||
132 | 217 | if isinstance(file_to_write, six.string_types): | 217 | if isinstance(file_to_write, six.string_types): |
133 | 218 | file_to_write = open(file_to_write, 'wb') | 218 | file_to_write = open(file_to_write, 'wb') |
134 | 219 | if not self.valid_files[hash]: | 219 | if not self.valid_files[hash]: |
136 | 220 | content = b"This is a %s" % hash | 220 | content = ("This is a %s" % hash).encode("ASCII") |
137 | 221 | else: | 221 | else: |
138 | 222 | with open(self.valid_files[hash], 'rb') as source: | 222 | with open(self.valid_files[hash], 'rb') as source: |
139 | 223 | content = source.read() | 223 | content = source.read() |
140 | diff --git a/lib/lp/services/daemons/tests/test_tachandler.py b/lib/lp/services/daemons/tests/test_tachandler.py | |||
141 | index 75d45a7..0b01898 100644 | |||
142 | --- a/lib/lp/services/daemons/tests/test_tachandler.py | |||
143 | +++ b/lib/lp/services/daemons/tests/test_tachandler.py | |||
144 | @@ -169,7 +169,7 @@ class TacTestSetupTestCase(testtools.TestCase): | |||
145 | 169 | with open(fixture.logfile, "wb") as logfile: | 169 | with open(fixture.logfile, "wb") as logfile: |
146 | 170 | logfile.write(b"One\n") | 170 | logfile.write(b"One\n") |
147 | 171 | logfile.write(b"Two\n") | 171 | logfile.write(b"Two\n") |
149 | 172 | logfile.write(b"Three, %s\n" % LOG_MAGIC.encode("UTF-8")) | 172 | logfile.write(("Three, %s\n" % LOG_MAGIC).encode("UTF-8")) |
150 | 173 | logfile.write(b"Four\n") | 173 | logfile.write(b"Four\n") |
151 | 174 | 174 | ||
152 | 175 | # Truncating the log leaves everything up to and including the line | 175 | # Truncating the log leaves everything up to and including the line |
153 | @@ -177,5 +177,5 @@ class TacTestSetupTestCase(testtools.TestCase): | |||
154 | 177 | fixture.truncateLog() | 177 | fixture.truncateLog() |
155 | 178 | with open(fixture.logfile, "rb") as logfile: | 178 | with open(fixture.logfile, "rb") as logfile: |
156 | 179 | self.assertEqual( | 179 | self.assertEqual( |
158 | 180 | b"One\nTwo\nThree, %s\n" % LOG_MAGIC.encode("UTF-8"), | 180 | ("One\nTwo\nThree, %s\n" % LOG_MAGIC).encode("UTF-8"), |
159 | 181 | logfile.read()) | 181 | logfile.read()) |
160 | diff --git a/lib/lp/services/librarianserver/doc/upload.txt b/lib/lp/services/librarianserver/doc/upload.txt | |||
161 | index ca8c26a..595b0b7 100644 | |||
162 | --- a/lib/lp/services/librarianserver/doc/upload.txt | |||
163 | +++ b/lib/lp/services/librarianserver/doc/upload.txt | |||
164 | @@ -108,13 +108,13 @@ Filename with spaces work. | |||
165 | 108 | 108 | ||
166 | 109 | Unicode filenames work, but must be encoded as UTF-8 on the socket. | 109 | Unicode filenames work, but must be encoded as UTF-8 on the socket. |
167 | 110 | 110 | ||
170 | 111 | >>> filename = 'Yow\N{INTERROBANG}'.encode('utf-8') | 111 | >>> filename = 'Yow\N{INTERROBANG}' |
171 | 112 | >>> upload_request(b"""STORE 14 %s | 112 | >>> upload_request(("""STORE 14 %s |
172 | 113 | ... Content-Type: text/plain | 113 | ... Content-Type: text/plain |
173 | 114 | ... File-Content-ID: 123 | 114 | ... File-Content-ID: 123 |
174 | 115 | ... File-Alias-ID: 456 | 115 | ... File-Alias-ID: 456 |
175 | 116 | ... Database-Name: right_database | 116 | ... Database-Name: right_database |
176 | 117 | ... | 117 | ... |
178 | 118 | ... Cats and dogs.""" % filename) | 118 | ... Cats and dogs.""" % filename).encode('UTF-8')) |
179 | 119 | reply: '200' | 119 | reply: '200' |
180 | 120 | file 'Yow‽' stored as text/plain, contents: 'Cats and dogs.' | 120 | file 'Yow‽' stored as text/plain, contents: 'Cats and dogs.' |
181 | diff --git a/lib/lp/soyuz/scripts/tests/test_copypackage.py b/lib/lp/soyuz/scripts/tests/test_copypackage.py | |||
182 | index 8fdf14e..1bce73c 100644 | |||
183 | --- a/lib/lp/soyuz/scripts/tests/test_copypackage.py | |||
184 | +++ b/lib/lp/soyuz/scripts/tests/test_copypackage.py | |||
185 | @@ -2068,9 +2068,9 @@ class TestCopyClosesBugs(TestCaseWithFactory): | |||
186 | 2068 | 2068 | ||
187 | 2069 | def createSource(self, version, archive, pocket, bug_id): | 2069 | def createSource(self, version, archive, pocket, bug_id): |
188 | 2070 | changes_template = ( | 2070 | changes_template = ( |
192 | 2071 | b"Format: 1.7\n" | 2071 | "Format: 1.7\n" |
193 | 2072 | b"Launchpad-bugs-fixed: %s\n") | 2072 | "Launchpad-bugs-fixed: %s\n") |
194 | 2073 | changes_file_content = changes_template % bug_id | 2073 | changes_file_content = (changes_template % bug_id).encode("UTF-8") |
195 | 2074 | source = self.test_publisher.getPubSource( | 2074 | source = self.test_publisher.getPubSource( |
196 | 2075 | sourcename='buggy-source', version=version, | 2075 | sourcename='buggy-source', version=version, |
197 | 2076 | distroseries=self.hoary_test, archive=archive, pocket=pocket, | 2076 | distroseries=self.hoary_test, archive=archive, pocket=pocket, |
198 | diff --git a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt | |||
199 | index f4ad646..ca2e9a1 100644 | |||
200 | --- a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt | |||
201 | +++ b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt | |||
202 | @@ -251,10 +251,10 @@ Sample Person can't access the file. | |||
203 | 251 | 251 | ||
204 | 252 | The 'No Privileges' user, the PPA owner, can download the DSC file. | 252 | The 'No Privileges' user, the PPA owner, can download the DSC file. |
205 | 253 | 253 | ||
207 | 254 | >>> print(http(br""" | 254 | >>> print(http(six.ensure_binary(r""" |
208 | 255 | ... GET %s HTTP/1.1 | 255 | ... GET %s HTTP/1.1 |
209 | 256 | ... Authorization: Basic no-priv@canonical.com:test | 256 | ... Authorization: Basic no-priv@canonical.com:test |
211 | 257 | ... """ % (dsc_file_lp_url.replace('http://launchpad.test', '')))) | 257 | ... """ % (dsc_file_lp_url.replace('http://launchpad.test', ''))))) |
212 | 258 | HTTP/1.1 303 See Other | 258 | HTTP/1.1 303 See Other |
213 | 259 | ... | 259 | ... |
214 | 260 | Location: https://...restricted.../test-pkg_1.0.dsc?token=... | 260 | Location: https://...restricted.../test-pkg_1.0.dsc?token=... |
215 | @@ -272,10 +272,10 @@ Binary files are served via '+files' rather than '+sourcefiles'. | |||
216 | 272 | Traceback (most recent call last): | 272 | Traceback (most recent call last): |
217 | 273 | ... | 273 | ... |
218 | 274 | zope.security.interfaces.Unauthorized | 274 | zope.security.interfaces.Unauthorized |
220 | 275 | >>> print(http(br""" | 275 | >>> print(http(six.ensure_binary(r""" |
221 | 276 | ... GET %s HTTP/1.1 | 276 | ... GET %s HTTP/1.1 |
222 | 277 | ... Authorization: Basic no-priv@canonical.com:test | 277 | ... Authorization: Basic no-priv@canonical.com:test |
224 | 278 | ... """ % (deb_file_lp_url.replace('http://launchpad.test', '')))) | 278 | ... """ % (deb_file_lp_url.replace('http://launchpad.test', ''))))) |
225 | 279 | HTTP/1.1 303 See Other | 279 | HTTP/1.1 303 See Other |
226 | 280 | ... | 280 | ... |
227 | 281 | Location: https://...restricted.../test-bin_1.0_all.deb?token=... | 281 | Location: https://...restricted.../test-bin_1.0_all.deb?token=... |
228 | @@ -314,9 +314,9 @@ binaries across to no-priv's public ppa. | |||
229 | 314 | >>> print(file_librarian_url) | 314 | >>> print(file_librarian_url) |
230 | 315 | http://.../test-pkg_1.0.dsc | 315 | http://.../test-pkg_1.0.dsc |
231 | 316 | 316 | ||
233 | 317 | >>> print(http(br""" | 317 | >>> print(http(six.ensure_binary(r""" |
234 | 318 | ... GET %s HTTP/1.1 | 318 | ... GET %s HTTP/1.1 |
236 | 319 | ... """ % file_lp_url.replace('http://launchpad.test', ''))) | 319 | ... """ % file_lp_url.replace('http://launchpad.test', '')))) |
237 | 320 | HTTP/1.1 303 See Other | 320 | HTTP/1.1 303 See Other |
238 | 321 | ... | 321 | ... |
239 | 322 | Location: http://.../test-pkg_1.0.dsc | 322 | Location: http://.../test-pkg_1.0.dsc |
240 | @@ -341,10 +341,10 @@ redirect to the files for the default named PPA. | |||
241 | 341 | >>> file_lp_url_without_ppa_name = ( | 341 | >>> file_lp_url_without_ppa_name = ( |
242 | 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') |
243 | 343 | 343 | ||
245 | 344 | >>> print(http(br""" | 344 | >>> print(http(six.ensure_binary(r""" |
246 | 345 | ... GET %s HTTP/1.1 | 345 | ... GET %s HTTP/1.1 |
247 | 346 | ... """ % file_lp_url_without_ppa_name.replace( | 346 | ... """ % file_lp_url_without_ppa_name.replace( |
249 | 347 | ... 'http://launchpad.test', ''))) | 347 | ... 'http://launchpad.test', '')))) |
250 | 348 | HTTP/1.1 301 Moved Permanently | 348 | HTTP/1.1 301 Moved Permanently |
251 | 349 | ... | 349 | ... |
252 | 350 | Location: http://localhost/~no-priv/+archive/ubuntu/ppa/+files/test-pkg_1.0.dsc | 350 | Location: http://localhost/~no-priv/+archive/ubuntu/ppa/+files/test-pkg_1.0.dsc |
253 | @@ -354,10 +354,10 @@ The same redirection happens for +archive/+build/blah urls: | |||
254 | 354 | 354 | ||
255 | 355 | >>> buildlog_lp_url_without_ppa_name = ( | 355 | >>> buildlog_lp_url_without_ppa_name = ( |
256 | 356 | ... 'http://launchpad.test/~no-priv/+archive/+build/1/+files/foo') | 356 | ... 'http://launchpad.test/~no-priv/+archive/+build/1/+files/foo') |
258 | 357 | >>> print(http(br""" | 357 | >>> print(http(six.ensure_binary(r""" |
259 | 358 | ... GET %s HTTP/1.1 | 358 | ... GET %s HTTP/1.1 |
260 | 359 | ... """ % buildlog_lp_url_without_ppa_name.replace( | 359 | ... """ % buildlog_lp_url_without_ppa_name.replace( |
262 | 360 | ... 'http://launchpad.test', ''))) | 360 | ... 'http://launchpad.test', '')))) |
263 | 361 | HTTP/1.1 301 Moved Permanently | 361 | HTTP/1.1 301 Moved Permanently |
264 | 362 | ... | 362 | ... |
265 | 363 | Location: http://.../~no-priv/+archive/ubuntu/ppa/+build/1/+files/... | 363 | Location: http://.../~no-priv/+archive/ubuntu/ppa/+build/1/+files/... |
266 | @@ -411,9 +411,9 @@ LP proxy URL a proper NotFound error is raised. | |||
267 | 411 | >>> print(file_lp_url) | 411 | >>> print(file_lp_url) |
268 | 412 | http://launchpad.test/~no-priv/+archive/ubuntu/ppa/+sourcefiles/test-pkg/1.0/test-pkg_1.0.dsc | 412 | http://launchpad.test/~no-priv/+archive/ubuntu/ppa/+sourcefiles/test-pkg/1.0/test-pkg_1.0.dsc |
269 | 413 | 413 | ||
271 | 414 | >>> not_found_file = http(br""" | 414 | >>> not_found_file = http(six.ensure_binary(r""" |
272 | 415 | ... GET %s HTTP/1.1 | 415 | ... GET %s HTTP/1.1 |
274 | 416 | ... """ % file_lp_url.replace('http://launchpad.test', '')) | 416 | ... """ % file_lp_url.replace('http://launchpad.test', ''))) |
275 | 417 | 417 | ||
276 | 418 | It results in a 404 response. | 418 | It results in a 404 response. |
277 | 419 | 419 | ||
278 | diff --git a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt | |||
279 | index b49a677..d9a96cc 100644 | |||
280 | --- a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt | |||
281 | +++ b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt | |||
282 | @@ -62,7 +62,7 @@ We create the POFile object where we are going to attach the .po file. | |||
283 | 62 | 62 | ||
284 | 63 | First, we do a valid import. | 63 | First, we do a valid import. |
285 | 64 | 64 | ||
287 | 65 | >>> pofile_contents = br''' | 65 | >>> pofile_contents = six.ensure_binary(r''' |
288 | 66 | ... msgid "" | 66 | ... msgid "" |
289 | 67 | ... msgstr "" | 67 | ... msgstr "" |
290 | 68 | ... "PO-Revision-Date: 2005-05-03 20:41+0100\n" | 68 | ... "PO-Revision-Date: 2005-05-03 20:41+0100\n" |
291 | @@ -74,7 +74,7 @@ First, we do a valid import. | |||
292 | 74 | ... | 74 | ... |
293 | 75 | ... msgid "foo" | 75 | ... msgid "foo" |
294 | 76 | ... msgstr "blah" | 76 | ... msgstr "blah" |
296 | 77 | ... ''' % datetime.datetime.now(UTC).isoformat() | 77 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
297 | 78 | >>> by_maintainer = False | 78 | >>> by_maintainer = False |
298 | 79 | >>> entry = translation_import_queue.addOrUpdateEntry( | 79 | >>> entry = translation_import_queue.addOrUpdateEntry( |
299 | 80 | ... pofile.path, pofile_contents, by_maintainer, person, | 80 | ... pofile.path, pofile_contents, by_maintainer, person, |
300 | @@ -110,7 +110,7 @@ file we just imported. | |||
301 | 110 | Now, we are going to import a .po file that has a 'PO-Revision-Date' | 110 | Now, we are going to import a .po file that has a 'PO-Revision-Date' |
302 | 111 | field with a date older than a previous .po import. | 111 | field with a date older than a previous .po import. |
303 | 112 | 112 | ||
305 | 113 | >>> pofile_contents = br''' | 113 | >>> pofile_contents = six.ensure_binary(r''' |
306 | 114 | ... msgid "" | 114 | ... msgid "" |
307 | 115 | ... msgstr "" | 115 | ... msgstr "" |
308 | 116 | ... "PO-Revision-Date: 2005-05-03 19:41+0100\n" | 116 | ... "PO-Revision-Date: 2005-05-03 19:41+0100\n" |
309 | @@ -122,7 +122,7 @@ field with a date older than a previous .po import. | |||
310 | 122 | ... | 122 | ... |
311 | 123 | ... msgid "foo" | 123 | ... msgid "foo" |
312 | 124 | ... msgstr "blah" | 124 | ... msgstr "blah" |
314 | 125 | ... ''' % datetime.datetime.now(UTC).isoformat() | 125 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
315 | 126 | >>> by_maintainer = False | 126 | >>> by_maintainer = False |
316 | 127 | >>> entry = translation_import_queue.addOrUpdateEntry( | 127 | >>> entry = translation_import_queue.addOrUpdateEntry( |
317 | 128 | ... pofile.path, pofile_contents, by_maintainer, person, | 128 | ... pofile.path, pofile_contents, by_maintainer, person, |
318 | diff --git a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt | |||
319 | index 44ce5f5..bc89865 100644 | |||
320 | --- a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt | |||
321 | +++ b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt | |||
322 | @@ -58,7 +58,7 @@ We create the POFile object where we are going to attach the .po file. | |||
323 | 58 | Let's import a .po file that misses the '"' char after msgstr. That's a | 58 | Let's import a .po file that misses the '"' char after msgstr. That's a |
324 | 59 | syntax error. | 59 | syntax error. |
325 | 60 | 60 | ||
327 | 61 | >>> pofile_contents = br''' | 61 | >>> pofile_contents = six.ensure_binary(r''' |
328 | 62 | ... msgid "" | 62 | ... msgid "" |
329 | 63 | ... msgstr "" | 63 | ... msgstr "" |
330 | 64 | ... "PO-Revision-Date: 2005-06-03 20:41+0100\n" | 64 | ... "PO-Revision-Date: 2005-06-03 20:41+0100\n" |
331 | @@ -70,7 +70,7 @@ syntax error. | |||
332 | 70 | ... | 70 | ... |
333 | 71 | ... msgid "foo" | 71 | ... msgid "foo" |
334 | 72 | ... msgstr blah" | 72 | ... msgstr blah" |
336 | 73 | ... ''' % datetime.datetime.now(UTC).isoformat() | 73 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
337 | 74 | >>> by_maintainer = False | 74 | >>> by_maintainer = False |
338 | 75 | >>> entry = translation_import_queue.addOrUpdateEntry( | 75 | >>> entry = translation_import_queue.addOrUpdateEntry( |
339 | 76 | ... pofile.path, pofile_contents, by_maintainer, person, | 76 | ... pofile.path, pofile_contents, by_maintainer, person, |
340 | @@ -194,7 +194,7 @@ In his rush to be the first Sumerian translator for Firefox, Mark | |||
341 | 194 | submits a translation with a nonsensical plurals definition. | 194 | submits a translation with a nonsensical plurals definition. |
342 | 195 | 195 | ||
343 | 196 | >>> pofile = potemplate.newPOFile('sux') | 196 | >>> pofile = potemplate.newPOFile('sux') |
345 | 197 | >>> pofile_contents = br''' | 197 | >>> pofile_contents = six.ensure_binary(r''' |
346 | 198 | ... msgid "" | 198 | ... msgid "" |
347 | 199 | ... msgstr "" | 199 | ... msgstr "" |
348 | 200 | ... "PO-Revision-Date: 2005-06-29 11:44+0100\n" | 200 | ... "PO-Revision-Date: 2005-06-29 11:44+0100\n" |
349 | @@ -205,7 +205,7 @@ submits a translation with a nonsensical plurals definition. | |||
350 | 205 | ... | 205 | ... |
351 | 206 | ... msgid "foo" | 206 | ... msgid "foo" |
352 | 207 | ... msgstr "bar" | 207 | ... msgstr "bar" |
354 | 208 | ... ''' % datetime.datetime.now(UTC).isoformat() | 208 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
355 | 209 | >>> entry = translation_import_queue.addOrUpdateEntry( | 209 | >>> entry = translation_import_queue.addOrUpdateEntry( |
356 | 210 | ... pofile.path, pofile_contents, False, person, | 210 | ... pofile.path, pofile_contents, False, person, |
357 | 211 | ... productseries=series, potemplate=potemplate, pofile=pofile) | 211 | ... productseries=series, potemplate=potemplate, pofile=pofile) |
358 | @@ -238,7 +238,7 @@ Not enough forms | |||
359 | 238 | Mark mistakenly attempts to import a translation with "zero" plural | 238 | Mark mistakenly attempts to import a translation with "zero" plural |
360 | 239 | forms. He receives an email notifying him of a syntax error. | 239 | forms. He receives an email notifying him of a syntax error. |
361 | 240 | 240 | ||
363 | 241 | >>> pofile_contents = br''' | 241 | >>> pofile_contents = six.ensure_binary(r''' |
364 | 242 | ... msgid "" | 242 | ... msgid "" |
365 | 243 | ... msgstr "" | 243 | ... msgstr "" |
366 | 244 | ... "PO-Revision-Date: 2005-06-14 18:33+0100\n" | 244 | ... "PO-Revision-Date: 2005-06-14 18:33+0100\n" |
367 | @@ -249,7 +249,7 @@ forms. He receives an email notifying him of a syntax error. | |||
368 | 249 | ... | 249 | ... |
369 | 250 | ... msgid "foo" | 250 | ... msgid "foo" |
370 | 251 | ... msgstr "bar" | 251 | ... msgstr "bar" |
372 | 252 | ... ''' % datetime.datetime.now(UTC).isoformat() | 252 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
373 | 253 | >>> entry = translation_import_queue.addOrUpdateEntry( | 253 | >>> entry = translation_import_queue.addOrUpdateEntry( |
374 | 254 | ... pofile.path, pofile_contents, False, person, | 254 | ... pofile.path, pofile_contents, False, person, |
375 | 255 | ... productseries=series, potemplate=potemplate, pofile=pofile) | 255 | ... productseries=series, potemplate=potemplate, pofile=pofile) |
376 | @@ -276,7 +276,7 @@ forms. He receives an email notifying him of a syntax error. | |||
377 | 276 | On his next attempt, Mark accidentally types a negative number of plural | 276 | On his next attempt, Mark accidentally types a negative number of plural |
378 | 277 | forms. The same error is given. | 277 | forms. The same error is given. |
379 | 278 | 278 | ||
381 | 279 | >>> pofile_contents = br''' | 279 | >>> pofile_contents = six.ensure_binary(r''' |
382 | 280 | ... msgid "" | 280 | ... msgid "" |
383 | 281 | ... msgstr "" | 281 | ... msgstr "" |
384 | 282 | ... "PO-Revision-Date: 2005-06-15 19:04+0100\n" | 282 | ... "PO-Revision-Date: 2005-06-15 19:04+0100\n" |
385 | @@ -287,7 +287,7 @@ forms. The same error is given. | |||
386 | 287 | ... | 287 | ... |
387 | 288 | ... msgid "foo" | 288 | ... msgid "foo" |
388 | 289 | ... msgstr "bar" | 289 | ... msgstr "bar" |
390 | 290 | ... ''' % datetime.datetime.now(UTC).isoformat() | 290 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
391 | 291 | >>> entry = translation_import_queue.addOrUpdateEntry( | 291 | >>> entry = translation_import_queue.addOrUpdateEntry( |
392 | 292 | ... pofile.path, pofile_contents, False, person, | 292 | ... pofile.path, pofile_contents, False, person, |
393 | 293 | ... productseries=series, potemplate=potemplate, pofile=pofile) | 293 | ... productseries=series, potemplate=potemplate, pofile=pofile) |
394 | @@ -325,7 +325,7 @@ to get that information corrected if need be. | |||
395 | 325 | >>> pofile = potemplate.newPOFile('ar') | 325 | >>> pofile = potemplate.newPOFile('ar') |
396 | 326 | 326 | ||
397 | 327 | # PO file with nplurals=7, a value we can't handle. | 327 | # PO file with nplurals=7, a value we can't handle. |
399 | 328 | >>> pofile_contents = br''' | 328 | >>> pofile_contents = six.ensure_binary(r''' |
400 | 329 | ... msgid "" | 329 | ... msgid "" |
401 | 330 | ... msgstr "" | 330 | ... msgstr "" |
402 | 331 | ... "PO-Revision-Date: 2005-07-01 08:35+0100\n" | 331 | ... "PO-Revision-Date: 2005-07-01 08:35+0100\n" |
403 | @@ -343,7 +343,7 @@ to get that information corrected if need be. | |||
404 | 343 | ... msgstr[4] "baros %%d" | 343 | ... msgstr[4] "baros %%d" |
405 | 344 | ... msgstr[5] "barorum %%d" | 344 | ... msgstr[5] "barorum %%d" |
406 | 345 | ... msgstr[6] "barim %%d" | 345 | ... msgstr[6] "barim %%d" |
408 | 346 | ... ''' % datetime.datetime.now(UTC).isoformat() | 346 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
409 | 347 | >>> entry = translation_import_queue.addOrUpdateEntry( | 347 | >>> entry = translation_import_queue.addOrUpdateEntry( |
410 | 348 | ... pofile.path, pofile_contents, False, person, | 348 | ... pofile.path, pofile_contents, False, person, |
411 | 349 | ... productseries=series, potemplate=potemplate, pofile=pofile) | 349 | ... productseries=series, potemplate=potemplate, pofile=pofile) |
412 | @@ -389,7 +389,7 @@ Once Mark has checked the language page and corrected the number of | |||
413 | 389 | plural forms, the file imports just fine. | 389 | plural forms, the file imports just fine. |
414 | 390 | 390 | ||
415 | 391 | # Same PO file as before, but with nplurals=6. | 391 | # Same PO file as before, but with nplurals=6. |
417 | 392 | >>> pofile_contents = br''' | 392 | >>> pofile_contents = six.ensure_binary(r''' |
418 | 393 | ... msgid "" | 393 | ... msgid "" |
419 | 394 | ... msgstr "" | 394 | ... msgstr "" |
420 | 395 | ... "PO-Revision-Date: 2005-07-01 08:35+0100\n" | 395 | ... "PO-Revision-Date: 2005-07-01 08:35+0100\n" |
421 | @@ -406,7 +406,7 @@ plural forms, the file imports just fine. | |||
422 | 406 | ... msgstr[3] "baribus %%d" | 406 | ... msgstr[3] "baribus %%d" |
423 | 407 | ... msgstr[4] "baros %%d" | 407 | ... msgstr[4] "baros %%d" |
424 | 408 | ... msgstr[5] "barorum %%d" | 408 | ... msgstr[5] "barorum %%d" |
426 | 409 | ... ''' % datetime.datetime.now(UTC).isoformat() | 409 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
427 | 410 | >>> entry = translation_import_queue.addOrUpdateEntry( | 410 | >>> entry = translation_import_queue.addOrUpdateEntry( |
428 | 411 | ... pofile.path, pofile_contents, False, person, | 411 | ... pofile.path, pofile_contents, False, person, |
429 | 412 | ... productseries=series, potemplate=potemplate, pofile=pofile) | 412 | ... productseries=series, potemplate=potemplate, pofile=pofile) |
430 | diff --git a/lib/lp/translations/doc/poimport.txt b/lib/lp/translations/doc/poimport.txt | |||
431 | index 1c49a97..5b07995 100644 | |||
432 | --- a/lib/lp/translations/doc/poimport.txt | |||
433 | +++ b/lib/lp/translations/doc/poimport.txt | |||
434 | @@ -56,7 +56,7 @@ And this is the POTemplate where the import will be done. | |||
435 | 56 | 56 | ||
436 | 57 | This is the file that'll get imported. | 57 | This is the file that'll get imported. |
437 | 58 | 58 | ||
439 | 59 | >>> potemplate_contents = br''' | 59 | >>> potemplate_contents = six.ensure_binary(r''' |
440 | 60 | ... msgid "" | 60 | ... msgid "" |
441 | 61 | ... msgstr "" | 61 | ... msgstr "" |
442 | 62 | ... "POT-Creation-Date: 2004-07-11 16:16+0900\n" | 62 | ... "POT-Creation-Date: 2004-07-11 16:16+0900\n" |
443 | @@ -86,7 +86,7 @@ This is the file that'll get imported. | |||
444 | 86 | ... | 86 | ... |
445 | 87 | ... msgid "translator-credits" | 87 | ... msgid "translator-credits" |
446 | 88 | ... msgstr "" | 88 | ... msgstr "" |
448 | 89 | ... ''' % datetime.datetime.now(UTC).isoformat() | 89 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
449 | 90 | 90 | ||
450 | 91 | We sometimes saw deadlocks as POFile statistics were updated after | 91 | We sometimes saw deadlocks as POFile statistics were updated after |
451 | 92 | importing a template. The operation would read all translation messages | 92 | importing a template. The operation would read all translation messages |
452 | @@ -226,7 +226,7 @@ Import With Errors | |||
453 | 226 | Here are the contents of the file we'll be importing. It has some | 226 | Here are the contents of the file we'll be importing. It has some |
454 | 227 | validation errors. | 227 | validation errors. |
455 | 228 | 228 | ||
457 | 229 | >>> pofile_with_errors = br''' | 229 | >>> pofile_with_errors = six.ensure_binary(r''' |
458 | 230 | ... msgid "" | 230 | ... msgid "" |
459 | 231 | ... msgstr "" | 231 | ... msgstr "" |
460 | 232 | ... "PO-Revision-Date: 2005-06-03 19:41+0100\n" | 232 | ... "PO-Revision-Date: 2005-06-03 19:41+0100\n" |
461 | @@ -257,7 +257,7 @@ validation errors. | |||
462 | 257 | ... msgstr[1] "Bars %%d" | 257 | ... msgstr[1] "Bars %%d" |
463 | 258 | ... msgstr[2] "Welsh power! %%d" | 258 | ... msgstr[2] "Welsh power! %%d" |
464 | 259 | ... msgstr[3] "We have four! %%d" | 259 | ... msgstr[3] "We have four! %%d" |
466 | 260 | ... ''' % datetime.datetime.now(UTC).isoformat() | 260 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
467 | 261 | 261 | ||
468 | 262 | This is the dbschema that controls the validation of a translation. | 262 | This is the dbschema that controls the validation of a translation. |
469 | 263 | 263 | ||
470 | @@ -423,7 +423,7 @@ instance) and they don't mean that any messages failed to import. | |||
471 | 423 | 423 | ||
472 | 424 | For example, here's a gettext PO file with two headers. | 424 | For example, here's a gettext PO file with two headers. |
473 | 425 | 425 | ||
475 | 426 | >>> pofile_with_warning = br''' | 426 | >>> pofile_with_warning = six.ensure_binary(r''' |
476 | 427 | ... msgid "" | 427 | ... msgid "" |
477 | 428 | ... msgstr "" | 428 | ... msgstr "" |
478 | 429 | ... "Content-Type: text/plain; charset=UTF-8\n" | 429 | ... "Content-Type: text/plain; charset=UTF-8\n" |
479 | @@ -439,7 +439,7 @@ For example, here's a gettext PO file with two headers. | |||
480 | 439 | ... | 439 | ... |
481 | 440 | ... msgid "a" | 440 | ... msgid "a" |
482 | 441 | ... msgstr "b" | 441 | ... msgstr "b" |
484 | 442 | ... ''' % datetime.datetime.now(UTC).isoformat() | 442 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
485 | 443 | >>> eo_pofile = potemplate.newPOFile('eo') | 443 | >>> eo_pofile = potemplate.newPOFile('eo') |
486 | 444 | >>> warning_entry = translation_import_queue.addOrUpdateEntry( | 444 | >>> warning_entry = translation_import_queue.addOrUpdateEntry( |
487 | 445 | ... 'eo.po', pofile_with_warning, False, potemplate.owner, | 445 | ... 'eo.po', pofile_with_warning, False, potemplate.owner, |
488 | @@ -484,7 +484,7 @@ Import Without Errors | |||
489 | 484 | Now, let's import one without errors. This file changes one translation | 484 | Now, let's import one without errors. This file changes one translation |
490 | 485 | and adds another one. | 485 | and adds another one. |
491 | 486 | 486 | ||
493 | 487 | >>> pofile_without_errors = br''' | 487 | >>> pofile_without_errors = six.ensure_binary(r''' |
494 | 488 | ... msgid "" | 488 | ... msgid "" |
495 | 489 | ... msgstr "" | 489 | ... msgstr "" |
496 | 490 | ... "PO-Revision-Date: 2005-06-03 20:41+0100\n" | 490 | ... "PO-Revision-Date: 2005-06-03 20:41+0100\n" |
497 | @@ -502,7 +502,7 @@ and adds another one. | |||
498 | 502 | ... | 502 | ... |
499 | 503 | ... msgid "translator-credits" | 503 | ... msgid "translator-credits" |
500 | 504 | ... msgstr "helpful@example.com" | 504 | ... msgstr "helpful@example.com" |
502 | 505 | ... ''' % datetime.datetime.now(UTC).isoformat() | 505 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
503 | 506 | >>> entry = translation_import_queue.addOrUpdateEntry( | 506 | >>> entry = translation_import_queue.addOrUpdateEntry( |
504 | 507 | ... pofile.path, pofile_without_errors, True, rosetta_experts, | 507 | ... pofile.path, pofile_without_errors, True, rosetta_experts, |
505 | 508 | ... distroseries=distroseries, sourcepackagename=sourcepackagename, | 508 | ... distroseries=distroseries, sourcepackagename=sourcepackagename, |
506 | @@ -645,7 +645,7 @@ plural forms). | |||
507 | 645 | 645 | ||
508 | 646 | We'll import a POFile with 3 plural forms into this POFile: | 646 | We'll import a POFile with 3 plural forms into this POFile: |
509 | 647 | 647 | ||
511 | 648 | >>> pofile_with_plurals = br''' | 648 | >>> pofile_with_plurals = six.ensure_binary(r''' |
512 | 649 | ... msgid "" | 649 | ... msgid "" |
513 | 650 | ... msgstr "" | 650 | ... msgstr "" |
514 | 651 | ... "PO-Revision-Date: 2005-06-03 19:41+0100\n" | 651 | ... "PO-Revision-Date: 2005-06-03 19:41+0100\n" |
515 | @@ -660,7 +660,7 @@ We'll import a POFile with 3 plural forms into this POFile: | |||
516 | 660 | ... msgstr[0] "First form %%d" | 660 | ... msgstr[0] "First form %%d" |
517 | 661 | ... msgstr[1] "Second form %%d" | 661 | ... msgstr[1] "Second form %%d" |
518 | 662 | ... msgstr[2] "Third form %%d" | 662 | ... msgstr[2] "Third form %%d" |
520 | 663 | ... ''' % datetime.datetime.now(UTC).isoformat() | 663 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
521 | 664 | 664 | ||
522 | 665 | We now import this POFile as this language's translation for the soure | 665 | We now import this POFile as this language's translation for the soure |
523 | 666 | package: | 666 | package: |
524 | diff --git a/lib/lp/translations/doc/rosetta-karma.txt b/lib/lp/translations/doc/rosetta-karma.txt | |||
525 | index f5bda21..caad946 100644 | |||
526 | --- a/lib/lp/translations/doc/rosetta-karma.txt | |||
527 | +++ b/lib/lp/translations/doc/rosetta-karma.txt | |||
528 | @@ -121,7 +121,7 @@ Let's say that we have this .po file to import: | |||
529 | 121 | >>> import datetime | 121 | >>> import datetime |
530 | 122 | >>> import pytz | 122 | >>> import pytz |
531 | 123 | >>> UTC = pytz.timezone('UTC') | 123 | >>> UTC = pytz.timezone('UTC') |
533 | 124 | >>> pofile_contents = br''' | 124 | >>> pofile_contents = six.ensure_binary(r''' |
534 | 125 | ... msgid "" | 125 | ... msgid "" |
535 | 126 | ... msgstr "" | 126 | ... msgstr "" |
536 | 127 | ... "Content-Type: text/plain; charset=UTF-8\n" | 127 | ... "Content-Type: text/plain; charset=UTF-8\n" |
537 | @@ -129,7 +129,7 @@ Let's say that we have this .po file to import: | |||
538 | 129 | ... | 129 | ... |
539 | 130 | ... msgid "foo" | 130 | ... msgid "foo" |
540 | 131 | ... msgstr "bar" | 131 | ... msgstr "bar" |
542 | 132 | ... ''' % datetime.datetime.now(UTC).isoformat() | 132 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
543 | 133 | >>> potemplate = POTemplate.get(1) | 133 | >>> potemplate = POTemplate.get(1) |
544 | 134 | >>> pofile = potemplate.getPOFileByLang('es') | 134 | >>> pofile = potemplate.getPOFileByLang('es') |
545 | 135 | 135 | ||
546 | @@ -193,7 +193,7 @@ Tell the PO file to import from the file data it has. | |||
547 | 193 | Now, the user is going to upload a local edition of the .po file. In this | 193 | Now, the user is going to upload a local edition of the .po file. In this |
548 | 194 | case, we will give karma *only* because the translation change. | 194 | case, we will give karma *only* because the translation change. |
549 | 195 | 195 | ||
551 | 196 | >>> pofile_contents = br''' | 196 | >>> pofile_contents = six.ensure_binary(r''' |
552 | 197 | ... msgid "" | 197 | ... msgid "" |
553 | 198 | ... msgstr "" | 198 | ... msgstr "" |
554 | 199 | ... "Content-Type: text/plain; charset=UTF-8\n" | 199 | ... "Content-Type: text/plain; charset=UTF-8\n" |
555 | @@ -201,7 +201,7 @@ case, we will give karma *only* because the translation change. | |||
556 | 201 | ... | 201 | ... |
557 | 202 | ... msgid "foo" | 202 | ... msgid "foo" |
558 | 203 | ... msgstr "bars" | 203 | ... msgstr "bars" |
560 | 204 | ... ''' % datetime.datetime.now(UTC).isoformat() | 204 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
561 | 205 | 205 | ||
562 | 206 | We attach the new file as not comming from upstream. | 206 | We attach the new file as not comming from upstream. |
563 | 207 | 207 | ||
564 | diff --git a/lib/lp/translations/doc/rosetta-poimport-script.txt b/lib/lp/translations/doc/rosetta-poimport-script.txt | |||
565 | index 8866db1..680c6a5 100644 | |||
566 | --- a/lib/lp/translations/doc/rosetta-poimport-script.txt | |||
567 | +++ b/lib/lp/translations/doc/rosetta-poimport-script.txt | |||
568 | @@ -32,17 +32,17 @@ the sampledata. | |||
569 | 32 | None | 32 | None |
570 | 33 | 33 | ||
571 | 34 | >>> pofile = potemplate.newPOFile('sr') | 34 | >>> pofile = potemplate.newPOFile('sr') |
573 | 35 | >>> pofile_content = br''' | 35 | >>> pofile_content = six.ensure_binary(''' |
574 | 36 | ... msgid "" | 36 | ... msgid "" |
575 | 37 | ... msgstr "" | 37 | ... msgstr "" |
580 | 38 | ... "PO-Revision-Date: 2005-06-04 20:41+0100\n" | 38 | ... "PO-Revision-Date: 2005-06-04 20:41+0100\\n" |
581 | 39 | ... "Last-Translator: Danilo Šegan <danilo@canonical.com>\n" | 39 | ... "Last-Translator: Danilo \u0160egan <danilo@canonical.com>\\n" |
582 | 40 | ... "Content-Type: text/plain; charset=UTF-8\n" | 40 | ... "Content-Type: text/plain; charset=UTF-8\\n" |
583 | 41 | ... "X-Rosetta-Export-Date: %s\n" | 41 | ... "X-Rosetta-Export-Date: %s\\n" |
584 | 42 | ... | 42 | ... |
585 | 43 | ... msgid "Foo %%s" | 43 | ... msgid "Foo %%s" |
586 | 44 | ... msgstr "Bar" | 44 | ... msgstr "Bar" |
588 | 45 | ... ''' % datetime.datetime.now(UTC).isoformat() | 45 | ... ''' % datetime.datetime.now(UTC).isoformat()) |
589 | 46 | 46 | ||
590 | 47 | We clean the import queue. | 47 | We clean the import queue. |
591 | 48 | 48 | ||
592 | diff --git a/lib/lp/translations/utilities/tests/test_translation_importer.py b/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
593 | index 106ca2d..624b84b 100644 | |||
594 | --- a/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
595 | +++ b/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
596 | @@ -235,7 +235,7 @@ class TranslationImporterTestCase(TestCaseWithFactory): | |||
597 | 235 | existing_translation = self.factory.makeCurrentTranslationMessage( | 235 | existing_translation = self.factory.makeCurrentTranslationMessage( |
598 | 236 | pofile=pofile, potmsgset=potmsgset1) | 236 | pofile=pofile, potmsgset=potmsgset1) |
599 | 237 | 237 | ||
601 | 238 | text = b""" | 238 | text = six.ensure_binary(""" |
602 | 239 | msgid "" | 239 | msgid "" |
603 | 240 | msgstr "" | 240 | msgstr "" |
604 | 241 | "MIME-Version: 1.0\\n" | 241 | "MIME-Version: 1.0\\n" |
605 | @@ -245,7 +245,7 @@ class TranslationImporterTestCase(TestCaseWithFactory): | |||
606 | 245 | 245 | ||
607 | 246 | msgid "%s" | 246 | msgid "%s" |
608 | 247 | msgstr "A translation." | 247 | msgstr "A translation." |
610 | 248 | """ % potmsgset2.msgid_singular.msgid | 248 | """ % potmsgset2.msgid_singular.msgid) |
611 | 249 | 249 | ||
612 | 250 | entry = self.factory.makeTranslationImportQueueEntry( | 250 | entry = self.factory.makeTranslationImportQueueEntry( |
613 | 251 | 'foo.po', potemplate=template, pofile=pofile, | 251 | 'foo.po', potemplate=template, pofile=pofile, |
Looks good!