Merge ~cjwatson/launchpad:combinecss-bytes into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: 99e09d1c7559b42dc2e63c67d0b05c7643caba91
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:combinecss-bytes
Merge into: launchpad:master
Diff against target: 32 lines (+7/-3)
2 files modified
lib/lp/scripts/utilities/js/combinecss.py (+3/-3)
lib/lp/scripts/utilities/js/combo.py (+4/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+377339@code.launchpad.net

Commit message

Make combinecss.main deal entirely in bytes

Description of the change

Also explain why we're dealing in bytes rather than text here (due to the interaction with cssutils), since it isn't obvious.

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

LGTM

Revision history for this message
Thiago F. Pappacena (pappacena) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/scripts/utilities/js/combinecss.py b/lib/lp/scripts/utilities/js/combinecss.py
2index bf52ed1..885d11c 100755
3--- a/lib/lp/scripts/utilities/js/combinecss.py
4+++ b/lib/lp/scripts/utilities/js/combinecss.py
5@@ -75,9 +75,9 @@ def main():
6
7 combo = ComboFile(absolute_names, target)
8 if combo.needs_update():
9- result = u''
10+ result = b''
11 for content in combine_files(names, icing):
12- result += content.decode('utf8')
13+ result += content
14
15 with open(target, 'wb') as f:
16- f.write(result.encode('utf8'))
17+ f.write(result)
18diff --git a/lib/lp/scripts/utilities/js/combo.py b/lib/lp/scripts/utilities/js/combo.py
19index f568bc2..b02e381 100644
20--- a/lib/lp/scripts/utilities/js/combo.py
21+++ b/lib/lp/scripts/utilities/js/combo.py
22@@ -41,6 +41,10 @@ def combine_files(fnames, root, resource_prefix=b"",
23 Returns an iterator with the combined content of all the
24 files. The relative path to root will be included as a comment
25 between each file.
26+
27+ Although CSS files are conceptually closer to text than bytes, we always
28+ yield bytes here since that's closer to what cssutils gives us, and it
29+ saves having to know the encoding.
30 """
31
32 combo_by_kind = {

Subscribers

People subscribed via source and target branches

to status/vote changes: