Ejemplo n.º 1
0
  def iter_configured_dependencies(cls, subject):
    """Return an iterator of the given subject's dependencies including any selected configurations.

    If no configuration is selected by a dependency (there is no `@[config-name]` specifier suffix),
    then `None` is returned for the paired configuration object; otherwise the `[config-name]` is
    looked for in the subject `configurations` list and returned if found or else an error is
    raised.

    :returns: An iterator over subjects dependencies as pairs of (dependency, configuration).
    :rtype: :class:`collections.Iterator` of (object, string)
    :raises: :class:`TaskPlanner.Error` if a dependency configuration was selected by subject but
             could not be found or was not unique.
    """
    for derivation in Subject.as_subject(subject).iter_derivations:
      if derivation.dependencies:
        for dep in derivation.dependencies:
          configuration = None
          if dep.address:
            config_specifier = extract_config_selector(dep.address)
            if config_specifier:
              if not dep.configurations:
                raise cls.Error('The dependency of {dependee} on {dependency} selects '
                                'configuration {config} but {dependency} has no configurations.'
                                .format(dependee=derivation,
                                        dependency=dep,
                                        config=config_specifier))
              configuration = dep.select_configuration(config_specifier)
          yield dep, configuration
Ejemplo n.º 2
0
  def iter_configured_dependencies(cls, subject):
    """Return an iterator of the given subject's dependencies including any selected configurations.

    If no configuration is selected by a dependency (there is no `@[config-name]` specifier suffix),
    then `None` is returned for the paired configuration object; otherwise the `[config-name]` is
    looked for in the subject `configurations` list and returned if found or else an error is
    raised.

    :returns: An iterator over subjects dependencies as pairs of (dependency, configuration).
    :rtype: :class:`collections.Iterator` of (object, string)
    :raises: :class:`TaskPlanner.Error` if a dependency configuration was selected by subject but
             could not be found or was not unique.
    """
    for derivation in Subject.as_subject(subject).iter_derivations:
      if derivation.dependencies:
        for dep in derivation.dependencies:
          configuration = None
          if dep.address:
            config_specifier = extract_config_selector(dep.address)
            if config_specifier:
              if not dep.configurations:
                raise cls.Error('The dependency of {dependee} on {dependency} selects '
                                'configuration {config} but {dependency} has no configurations.'
                                .format(dependee=derivation,
                                        dependency=dep,
                                        config=config_specifier))
              configuration = dep.select_configuration(config_specifier)
          yield dep, configuration
Ejemplo n.º 3
0
  def iter_configured_dependencies(cls, subject):
    """Return an iterator of the given subject's dependencies including any selected configurations.

    If no configuration is selected by a dependency (there is no `@[config-name]` specifier suffix),
    then `None` is returned for the paired configuration object; otherwise the `[config-name]` is
    looked for in the subject `configurations` list and returned if found or else an error is
    raised.

    :returns: An iterator over subjects dependencies as pairs of (dependency, configuration).
    :rtype: :class:`collections.Iterator` of (object, string)
    :raises: :class:`TaskPlanner.Error` if a dependency configuration was selected by subject but
             could not be found or was not unique.
    """
    for derivation in Subject.as_subject(subject).iter_derivations:
      if derivation.dependencies:
        for dep in derivation.dependencies:
          configuration = None
          if dep.address:
            config_specifier = extract_config_selector(dep.address)
            if config_specifier:
              if not dep.configurations:
                raise cls.Error('The dependency of {dependee} on {dependency} selects '
                                'configuration {config} but {dependency} has no configurations.'
                                .format(dependee=derivation,
                                        dependency=dep,
                                        config=config_specifier))
              configs = tuple(config for config in dep.configurations
                              if config.name == config_specifier)
              if len(configs) != 1:
                configurations = ('{} -> {!r}'.format(repr(c.name) if c.name else '<anonymous>', c)
                                  for c in configs)
                raise cls.Error('Failed to find config named {config} selected by {dependee} '
                                'amongst these configurations in {dependency}:\n\t{configurations}'
                                .format(config=config_specifier,
                                        dependee=derivation,
                                        dependency=dep,
                                        configurations='\n\t'.join(configurations)))
              configuration = configs[0]
          yield dep, configuration