def _expand_subsystems()

in src/python/pants/help/scope_info_iterator.py [0:0]


  def _expand_subsystems(self, scope_infos):
    """Add all subsystems tied to a scope, right after that scope."""

    # Get non-global subsystem dependencies of the specified subsystem client.
    def subsys_deps(subsystem_client_cls):
      for dep in subsystem_client_cls.subsystem_dependencies_iter():
        if dep.scope != GLOBAL_SCOPE:
          yield self._scope_to_info[dep.options_scope]
          for x in subsys_deps(dep.subsystem_cls):
            yield x

    for scope_info in scope_infos:
      yield scope_info
      if scope_info.optionable_cls is not None:
        # We don't currently subclass GlobalOptionsRegistrar, and I can't think of any reason why
        # we would, but might as well be robust.
        if issubclass(scope_info.optionable_cls, GlobalOptionsRegistrar):
          # We were asked for global help, so also yield for all global subsystems.
          for scope, info in self._scope_to_info.items():
            if info.category == ScopeInfo.SUBSYSTEM and enclosing_scope(scope) == GLOBAL_SCOPE:
              yield info
              for subsys_dep in subsys_deps(info.optionable_cls):
                yield subsys_dep
        elif issubclass(scope_info.optionable_cls, SubsystemClientMixin):
          for subsys_dep in subsys_deps(scope_info.optionable_cls):
            yield subsys_dep