def _get_option_to_record(self, scope, option=None):
    """Looks up an option scope (and optionally option therein) in the options parsed by Pants.

    Returns a dict of of all options in the scope, if option is None.
    Returns the specific option if option is not None.
    Raises ValueError if scope or option could not be found.
    """
    scope_to_look_up = scope if scope != 'GLOBAL' else ''
    try:
      value = self._all_options.for_scope(scope_to_look_up, inherit_from_enclosing_scope=False).as_dict()
      if option is None:
        return value
      else:
        return value[option]
    except (Config.ConfigValidationError, AttributeError) as e:
      raise ValueError("Couldn't find option scope {}{} for recording ({})".format(
        scope,
        "" if option is None else " option {}".format(option),
        e
      ))
Looks up an option scope (and optionally option therein) in the options parsed by Pants.

    Returns a dict of of all options in the scope, if option is None.
    Returns the specific option if option is not None.
    Raises ValueError if scope or option could not be found.