|
22 | 22 | import re |
23 | 23 | import config |
24 | 24 |
|
| 25 | +from optparse import OptionParser, BadOptionError, AmbiguousOptionError |
25 | 26 |
|
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) |
27 | 39 |
|
28 | 40 | # Parse command line options |
29 | 41 | usage = "usage: %prog [--root]" |
30 | | -parser = OptionParser(usage=usage) |
| 42 | +parser = PassThroughOptionParser(usage=usage) |
31 | 43 | 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) |
32 | 44 | parser.add_option("-w", "--wx28", action="store_true", dest="force28", help="Force usage of wxPython 2.8", default=False) |
33 | 45 | parser.add_option("-d", "--debug", action="store_true", dest="debug", help="Set logger to debug level.", default=False) |
|
0 commit comments