Esempio n. 1
0
    def from_dict(as_dict):
        if as_dict is None:
            return None

        requirements_dicts = as_dict.get('requirements', [])
        requirements = [ToolRequirement.from_dict(r) for r in requirements_dicts]
        installed_tool_dependencies_dicts = as_dict.get('installed_tool_dependencies', [])
        installed_tool_dependencies = map(DependenciesDescription._toolshed_install_dependency_from_dict, installed_tool_dependencies_dicts)
        return DependenciesDescription(
            requirements=requirements,
            installed_tool_dependencies=installed_tool_dependencies
        )
def get_dependencies(builder):  # type: (HasReqsHints) -> ToolRequirements
    (software_requirement, _) = builder.get_requirement("SoftwareRequirement")
    dependencies = []  # type: List[ToolRequirement]
    if software_requirement and software_requirement.get("packages"):
        packages = software_requirement.get("packages")
        for package in packages:
            version = package.get("version", None)
            if isinstance(version, MutableSequence):
                if version:
                    version = version[0]
                else:
                    version = None
            specs = [{"uri": s} for s in package.get("specs", [])]
            dependencies.append(ToolRequirement.from_dict(dict(
                name=package["package"].split("#")[-1],
                version=version,
                type="package",
                specs=specs,
            )))

    return ToolRequirements.from_list(dependencies)
Esempio n. 3
0
def get_dependencies(builder):  # type: (HasReqsHints) -> ToolRequirements
    (software_requirement, _) = builder.get_requirement("SoftwareRequirement")
    dependencies = []  # type: List[ToolRequirement]
    if software_requirement and software_requirement.get("packages"):
        packages = software_requirement.get("packages")
        for package in packages:
            version = package.get("version", None)
            if isinstance(version, MutableSequence):
                if version:
                    version = version[0]
                else:
                    version = None
            specs = [{"uri": s} for s in package.get("specs", [])]
            dependencies.append(ToolRequirement.from_dict(dict(
                name=package["package"].split("#")[-1],
                version=version,
                type="package",
                specs=specs,
            )))

    return ToolRequirements.from_list(dependencies)
Esempio n. 4
0
def test_tool_requirement_equality():
    a = ToolRequirement.from_dict(REQUIREMENT_A)
    assert a == ToolRequirement(**REQUIREMENT_A)
    b = ToolRequirement(**REQUIREMENT_B)
    assert a != b
Esempio n. 5
0
def test_tool_requirement_equality():
    a = ToolRequirement.from_dict(REQUIREMENT_A)
    assert a == ToolRequirement(**REQUIREMENT_A)
    b = ToolRequirement(**REQUIREMENT_B)
    assert a != b