]> 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)
committerJulien Rioux <jrioux@physics.utoronto.ca>
Thu, 8 Nov 2012 20:13:04 +0000 (15:13 -0500)
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 8aaa57ab8bc24ce5d10a8e0d8cc174f121b9445f..647061f4c710d46066b9e1aa20134bbd52fef291 100644 (file)
@@ -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