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.17.7-1~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a49f2bc12dc1ebf3de6da4573c3b296643d27e40;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 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