| 552 | # -- Constructor/initialization methods ---------------------------- |
| 553 | |
| 554 | def __init__(self, *opts, **attrs): |
| 555 | # Set _short_opts, _long_opts attrs from 'opts' tuple. |
| 556 | # Have to be set now, in case no option strings are supplied. |
| 557 | self._short_opts = [] |
| 558 | self._long_opts = [] |
| 559 | opts = self._check_opt_strings(opts) |
| 560 | self._set_opt_strings(opts) |
| 561 | |
| 562 | # Set all other attrs (action, type, etc.) from 'attrs' dict |
| 563 | self._set_attrs(attrs) |
| 564 | |
| 565 | # Check all the attributes we just set. There are lots of |
| 566 | # complicated interdependencies, but luckily they can be farmed |
| 567 | # out to the _check_*() methods listed in CHECK_METHODS -- which |
| 568 | # could be handy for subclasses! The one thing these all share |
| 569 | # is that they raise OptionError if they discover a problem. |
| 570 | for checker in self.CHECK_METHODS: |
| 571 | checker(self) |
| 572 | |
| 573 | def _check_opt_strings(self, opts): |
| 574 | # Filter out None because early versions of Optik had exactly |