damned-lies r1521 - in trunk: . vertimus
- From: claudep svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1521 - in trunk: . vertimus
- Date: Wed, 1 Apr 2009 07:08:08 +0000 (UTC)
Author: claudep
Date: Wed Apr 1 07:08:08 2009
New Revision: 1521
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1521&view=rev
Log:
2009-04-01 Claude Paroz <claude 2xlibre net>
* vertimus/views.py: Catch Unicode decoding errors on file content
conversion.
Modified:
trunk/ChangeLog
trunk/vertimus/views.py
Modified: trunk/vertimus/views.py
==============================================================================
--- trunk/vertimus/views.py (original)
+++ trunk/vertimus/views.py Wed Apr 1 07:08:08 2009
@@ -122,7 +122,11 @@
# The merged file isn't availabe yet
file_path_1 = action_1.file.path
- content_1 = [l.decode('utf-8') for l in open(file_path_1, 'U').readlines()]
+ try:
+ content_1 = [l.decode('utf-8') for l in open(file_path_1, 'U').readlines()]
+ except UnicodeDecodeError:
+ return render_to_response('error.html',
+ {'error': _("Error: The file %s contains invalid characters.") % file_path_1.split('/')[-1]})
descr_1 = _("Uploaded file by %(name)s on %(date)s") % { 'name': action_1.person.name,
'date': action_1.created }
if action_id_2 not in (None, "0"):
@@ -150,8 +154,11 @@
stats = get_object_or_404(Statistics, branch=state.branch, domain=state.domain, language=None)
descr_2 = _("Latest POT file")
file_path_2 = stats.po_path()
-
- content_2 = [l.decode('utf-8') for l in open(file_path_2, 'U').readlines()]
+ try:
+ content_2 = [l.decode('utf-8') for l in open(file_path_2, 'U').readlines()]
+ except UnicodeDecodeError:
+ return render_to_response('error.html',
+ {'error': _("Error: The file %s contains invalid characters.") % file_path_2.split('/')[-1]})
d = difflib.HtmlDiff(wrapcolumn=80)
diff_content = d.make_table(content_2, content_1,
descr_2, descr_1, context=True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]