aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/config.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-01-21 07:19:44 +0100
committerGuido Günther <agx@sigxcpu.org>2016-01-21 07:31:18 +0100
commit35bd093122032faacdcfb812c3749922bb279a68 (patch)
tree76cb87b3db83d114822a982effb1d191b2172c87 /gbp/config.py
parent92b7f1bfed9df905932d269fdfde270be9a77d76 (diff)
Don't throw exception when printing help an getting EPIPE
Python's optparse does not ignore EPIPE so just add our own print_help().
Diffstat (limited to 'gbp/config.py')
-rw-r--r--gbp/config.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 934dbe95..3d254eee 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -19,7 +19,10 @@
from optparse import OptionParser, OptionGroup, Option, OptionValueError
from six.moves import configparser
from copy import copy
+import errno
import os.path
+import sys
+
try:
from gbp.version import gbp_version
@@ -549,6 +552,20 @@ class GbpOptionParser(OptionParser):
"""
return self.config.get(option_name)
+ def print_help(self, file=None):
+ """
+ Print an extended help message, listing all options and any
+ help text provided with them, to 'file' (default stdout).
+ """
+ if file is None:
+ file = sys.stdout
+ encoding = self._get_encoding(file)
+ try:
+ file.write(self.format_help().encode(encoding, "replace"))
+ except IOError as e:
+ if e.errno != errno.EPIPE:
+ raise
+
@classmethod
def _name_to_filename(cls, name):
"""