]> git.donarmstrong.com Git - lilypond.git/commitdiff
Gobble empty strings passed as arguments to python scripts.
authorJulien Rioux <jrioux@physics.utoronto.ca>
Thu, 1 Nov 2012 10:19:36 +0000 (06:19 -0400)
committerPhil Holmes <mail@philholmes.net>
Fri, 4 Jan 2013 11:27:17 +0000 (11:27 +0000)
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

index afebefb7a807f12aea5b5a7936b97fb35a919721..7e3eb410bdec1014c61f95bf58f4318b40463862 100644 (file)
@@ -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