From a49f2bc12dc1ebf3de6da4573c3b296643d27e40 Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Thu, 1 Nov 2012 06:19:36 -0400 Subject: [PATCH] Gobble empty strings passed as arguments to python scripts. This is needed on windows in combination with the fix to issue 1455. Either we go this way, or we revert the fix to issue 1455. Should also be considered a candidate for the 2.16 stable branch. --- python/lilylib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/lilylib.py b/python/lilylib.py index 8aaa57ab8b..647061f4c7 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -335,8 +335,15 @@ class NonDentedHeadingFormatter (optparse.IndentedHelpFormatter): def format_description(self, description): return description +class NonEmptyOptionParser (optparse.OptionParser): + "A subclass of OptionParser that gobbles empty string arguments." + + def parse_args (self, args=None, values=None): + options, args = optparse.OptionParser.parse_args (self, args, values) + return options, filter (None, args) + def get_option_parser (*args, **kwargs): - p = optparse.OptionParser (*args, **kwargs) + p = NonEmptyOptionParser (*args, **kwargs) p.formatter = NonDentedHeadingFormatter () p.formatter.set_parser (p) return p -- 2.39.5