From 9899681e41107bde5ec1a4e58e61bdd48155d508 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 afebefb7a8..7e3eb410bd 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -330,8 +330,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