Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Commit

Permalink
Fix bug: allow non-ASCII chars in sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
ulif committed Sep 26, 2013
1 parent 2031e95 commit 8bcede4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/z3c/coverage/coveragereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
'--language=html', '--highlight=python', '--color',
'-o', '-']

#: Expected encoding of highlight command (enscript).
HIGHLIGHT_CMD_ENCODING = 'latin1'

class Lazy(object):
"""Descriptor for lazy evaluation"""
Expand Down Expand Up @@ -412,7 +414,9 @@ def key(node_info):
continue # skip root node
print_table_row(html, node, file_index)
print('</table><hr/>', file=html)
print(tree.get_at(my_index).html_source, file=html)
print(
(tree.get_at(my_index).html_source).encode(HIGHLIGHT_CMD_ENCODING),
file=html)
print(FOOTER % footer, file=html)
html.close()

Expand All @@ -432,7 +436,7 @@ def syntax_highlight(filename):
with open(filename, 'r') as file:
text = cgi.escape(file.read())
else:
text = text.decode('ascii')
text = text.decode(HIGHLIGHT_CMD_ENCODING)
text = text[text.find('<PRE>')+len('<PRE>'):]
text = text[:text.find('</PRE>')]
return text
Expand Down

0 comments on commit 8bcede4

Please sign in to comment.