[jhbuild] [commands] make OptionParser handle unicode error messages
- From: Frederic Peters <fpeters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [jhbuild] [commands] make OptionParser handle unicode error messages
- Date: Mon, 24 Aug 2009 15:23:29 +0000 (UTC)
commit 147052ab1ee96408d005bc69e9e237c7950f3e3a
Author: Frédéric Péters <fpeters 0d be>
Date: Mon Aug 24 17:22:32 2009 +0200
[commands] make OptionParser handle unicode error messages
jhbuild/commands/__init__.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/jhbuild/commands/__init__.py b/jhbuild/commands/__init__.py
index bd375c3..f19f216 100644
--- a/jhbuild/commands/__init__.py
+++ b/jhbuild/commands/__init__.py
@@ -25,10 +25,18 @@ __all__ = [
]
import optparse
+import sys
from jhbuild.errors import UsageError, FatalError
+class OptionParser(optparse.OptionParser):
+ def exit(self, status=0, msg=None):
+ if msg:
+ sys.stderr.write(uencode(msg))
+ sys.exit(status)
+
+
class Command:
"""Base class for Command objects"""
@@ -44,7 +52,7 @@ class Command:
return self.run(config, options, args)
def parse_args(self, args):
- self.parser = optparse.OptionParser(
+ self.parser = OptionParser(
usage='%%prog %s %s' % (self.name, _(self.usage_args)),
description=_(self.doc))
self.parser.add_options(self.options)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]