@property
    def parser(self):

        if getattr(self, '_parser', None):
            return self._parser

        self._parser = parser = optparse.OptionParser(add_help_option=False,
            usage="%%prog %s [options]" % self.name)

        parser.disable_interspersed_args()
        parser.add_option('-h', '--help', action="store_true",
                        help="display this help information")

        needs_tasks = [(environment.get_task(task), task) for task in self.needs_closure]

        # backward compatibility: tasks that inherit from Task and override constructor
        if getattr(self, "might_call", None):
            needs_tasks.extend((environment.get_task(task), task) for task in self.might_call)

        shared_tasks = {}
        parser.mirrored_options = {}
        parser.options_to_hide_from_help = []

        for task, task_name in itertools.chain([(self, self.name)], needs_tasks):
            if not task:
                raise PavementError("Task %s needed by %s does not exist"
                    % (task_name, self))

            for option in task.user_options:
                add_options = True
                try:
                    if not isinstance(option, optparse.Option):
                        option = self._make_option_from_tuple(option)

                    environment.debug("Task %s: adding option %s" %
                                     (self.name, str(option)))

                    try:
                        longname = option._long_opts[0]
                    except IndexError:
                        longname = None

                    try:
                        shortname = option._short_opts[0]
                    except IndexError:
                        shortname = None

                    # XXX: this probably needs refactored to handle commands with multiple
                    # long or short options
                    task_share_options_with = task.share_options_with or []
                    task_shares = [environment.get_task(t).name for t in task_share_options_with if environment.get_task(t)]

                    if self.share_options_with or task_shares:
                        options = (shortname, longname)

                        # either I am sharing with dependent task
                        # ...or it can share with me
                        if (
                                options in shared_tasks and (shared_tasks[options] or self.share_options_with)
                            ) \
                            or \
                            (
                                self.name in [environment.get_task(t).name for t in task_share_options_with if environment.get_task(t)]
                            ):
                            environment.debug("Task %s: NOT adding option %s," \
                                "already present; setting up mirror" %
                                             (self.name, option))

                            if parser.mirrored_options not in option.dest:
                                parser.mirrored_options[option.dest] = []
                            parser.mirrored_options[option.dest].append(task_name)
                            add_options = False

                        if options not in shared_tasks:
                            shared_tasks[options] = set()

                        if task_share_options_with:
                            shared_tasks[options] |= set(task_share_options_with)

                    if add_options:
                        try:
                            parser.add_option(option)
                        except optparse.OptionConflictError:
                            raise PavementError("""In setting command options for %r,
    option %s for %r is already in use
    by another task in the dependency chain.""" % (self, option, task))
                        # add just names; longname now contains --initial-dashes
                        self.option_names.add((task.shortname, longname[2:], option.dest))

                        if getattr(task, 'no_help', False):
                            if shortname:
                                parser.options_to_hide_from_help.append(shortname)
                            elif longname:
                                parser.options_to_hide_from_help.append(longname)
                except IndexError:
                    raise PavementError("Invalid option format provided for %r: %s"
                                        % (self, option))

        return parser
dataset/ETHPy150Open paver/paver/paver/tasks.py/Task.parser/swapped operands of `not in`