From: Radek Czajka Date: Thu, 7 Jul 2011 12:02:35 +0000 (+0200) Subject: dirty workaround for python unicode problems X-Git-Tag: 1.7~201 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/82e604c583fb1efdb6d988ea7e8673f8f7c8f119?hp=28878296bacad453735a520f350ba5a971f8ffc8 dirty workaround for python unicode problems --- 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