Merge ~cjwatson/launchpad:py3-apidoc-bytes-text into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 4dac336265de62d75a3ee3036271b092f6ea981a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-apidoc-bytes-text
Merge into: launchpad:master
Diff against target: 22 lines (+3/-3)
1 file modified
utilities/create-lp-wadl-and-apidoc.py (+3/-3)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+381334@code.launchpad.net

Commit message

Fix bytes/text handling in create-lp-wadl-and-apidoc.py

Description of the change

generate_wadl and generate_html produce bytes, while generate_json produces text. It's easiest to just handle either.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/utilities/create-lp-wadl-and-apidoc.py b/utilities/create-lp-wadl-and-apidoc.py
2index a2255ff..7157a1a 100755
3--- a/utilities/create-lp-wadl-and-apidoc.py
4+++ b/utilities/create-lp-wadl-and-apidoc.py
5@@ -22,6 +22,7 @@ import subprocess
6 import sys
7
8 from lazr.restful.interfaces import IWebServiceConfiguration
9+import six
10 from zope.component import getUtility
11 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
12
13@@ -36,9 +37,8 @@ from lp.systemhomes import WebServiceApplication
14
15 def write(filename, content, timestamp):
16 """Replace the named file with the given string."""
17- f = open(filename, 'w')
18- f.write(content)
19- f.close()
20+ with open(filename, 'wb') as f:
21+ f.write(six.ensure_binary(content))
22 os.utime(filename, (timestamp, timestamp)) # (atime, mtime)
23
24

Subscribers

People subscribed via source and target branches

to status/vote changes: