Skip to content

Commit 3cb6d03

Browse files
committed
Fix issue with OSX passing an unknown argument
1 parent 81f1224 commit 3cb6d03

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

pyfa.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@
2222
import re
2323
import config
2424

25+
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
2526

26-
from optparse import OptionParser
27+
class PassThroughOptionParser(OptionParser):
28+
"""
29+
An unknown option pass-through implementation of OptionParser.
30+
31+
OSX passes -psn_0_* argument, which is something that pyfa does not handle. See GH issue #423
32+
"""
33+
def _process_args(self, largs, rargs, values):
34+
while rargs:
35+
try:
36+
OptionParser._process_args(self,largs,rargs,values)
37+
except (BadOptionError,AmbiguousOptionError), e:
38+
largs.append(e.opt_str)
2739

2840
# Parse command line options
2941
usage = "usage: %prog [--root]"
30-
parser = OptionParser(usage=usage)
42+
parser = PassThroughOptionParser(usage=usage)
3143
parser.add_option("-r", "--root", action="store_true", dest="rootsavedata", help="if you want pyfa to store its data in root folder, use this option", default=False)
3244
parser.add_option("-w", "--wx28", action="store_true", dest="force28", help="Force usage of wxPython 2.8", default=False)
3345
parser.add_option("-d", "--debug", action="store_true", dest="debug", help="Set logger to debug level.", default=False)

0 commit comments

Comments
 (0)