Example #1
0
    def test_secondary_files(self):
        dep = _make_dep()
        primary_path = Path('path/to/file.txt')
        secondary_path = Path('path/to/file_2.txt')
        file_set = DependencyPathSet(dep, primary_path)

        with pytest.raises(AttributeError) as info:
            print(file_set.source_path)

        assert info.value.args[
            0] == "'DependencyPathSet' object has no attribute 'source_path'"

        file_set.add_secondary_path('source_path', secondary_path)

        assert file_set.source_path is secondary_path
Example #2
0
def _try_to_add_secondary_path(context: DependencyContext, dependency: Dependency, key: str, name: str,
                               path_set: DependencyPathSet, signatures: Optional[Dict[str, str]] = None):
    """
    A function that attempts to load a secondary path (sources or javadoc) and, if
    successful, adds them to the given path set.

    :param context: the current dependency context in play.
    :param dependency: the dependency we are to resolve.
    :param key: the key by which the secondary path will be known.
    :param name: the name of the secondary path.
    :param path_set: the path set to add a successfully isolated path to.
    :param signatures: the set of signatures to verify against (if any).
    """
    path = context.to_local_path(dependency, name, signatures)

    if path:
        path_set.add_secondary_path(key, path)