From 82e604c583fb1efdb6d988ea7e8673f8f7c8f119 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 7 Jul 2011 14:02:35 +0200 Subject: [PATCH] dirty workaround for python unicode problems --- librarian/__init__.py | 8 +++++++- scripts/book2epub | 2 +- scripts/book2html | 4 ++-- scripts/book2pdf | 2 +- scripts/book2txt | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/librarian/__init__.py b/librarian/__init__.py index 5c4a355..5b6981d 100644 --- a/librarian/__init__.py +++ b/librarian/__init__.py @@ -6,7 +6,13 @@ import os class ParseError(Exception): - pass + def __str__(self): + """ Dirty workaround for Python Unicode handling problems. """ + return self.message.message + + def __unicode__(self): + """ Dirty workaround for Python Unicode handling problems. """ + return self.message.message class ValidationError(Exception): pass diff --git a/scripts/book2epub b/scripts/book2epub index 502d965..9adf4b4 100755 --- a/scripts/book2epub +++ b/scripts/book2epub @@ -53,5 +53,5 @@ if __name__ == '__main__': print '%(file)s:%(name)s:%(message)s' % { 'file': main_input, 'name': e.__class__.__name__, - 'message': e.message + 'message': e } diff --git a/scripts/book2html b/scripts/book2html index f42c0ff..d61b299 100755 --- a/scripts/book2html +++ b/scripts/book2html @@ -40,7 +40,7 @@ if __name__ == '__main__': print '%(file)s:%(name)s:%(message)s' % { 'file': input_filename, 'name': e.__class__.__name__, - 'message': e.message + 'message': e, } except IOError, e: print '%(file)s:%(name)s:%(message)s' % { @@ -52,7 +52,7 @@ if __name__ == '__main__': print '%(file)s:%(etype)s:%(message)s' % { 'file': input_filename, 'etype': e.__class__.__name__, - 'message': e.message, + 'message': e, } raise diff --git a/scripts/book2pdf b/scripts/book2pdf index 532577c..d10f400 100755 --- a/scripts/book2pdf +++ b/scripts/book2pdf @@ -62,5 +62,5 @@ if __name__ == '__main__': print '%(file)s:%(name)s:%(message)s; use -v to see more output' % { 'file': main_input, 'name': e.__class__.__name__, - 'message': e.message + 'message': e } diff --git a/scripts/book2txt b/scripts/book2txt index f77e512..d56d6ff 100755 --- a/scripts/book2txt +++ b/scripts/book2txt @@ -45,7 +45,7 @@ if __name__ == '__main__': print '%(file)s:%(name)s:%(message)s' % { 'file': input_filename, 'name': e.__class__.__name__, - 'message': e.message + 'message': e } except IOError, e: print '%(file)s:%(name)s:%(message)s' % { @@ -57,6 +57,6 @@ if __name__ == '__main__': print '%(file)s:%(etype)s:%(message)s' % { 'file': input_filename, 'etype': e.__class__.__name__, - 'message': e.message, + 'message': e, } raise -- 2.20.1