From: Julien Rioux Date: Thu, 1 Nov 2012 10:19:36 +0000 (-0400) Subject: Gobble empty strings passed as arguments to python scripts. X-Git-Tag: release/2.16.2-1~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9899681e41107bde5ec1a4e58e61bdd48155d508;p=lilypond.git 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. --- 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