Skip to content

ParameterHasValue

Bases: Condition

Source code in src/library_analyzer/processing/api/_extract_dependencies.py
class ParameterHasValue(Condition):
    def __init__(
        self,
        cond: str,
        dependee: str,
        value: str,
        combined_with: list[Condition] | None = None,
        check_dependee: bool = False,
        also: bool = False,
    ) -> None:
        combined_with_list = combined_with if combined_with is not None else []
        super().__init__(cond, dependee, combined_with_list)
        self.check_dependee: bool = check_dependee
        self.value: str = value
        self.also = also

    @classmethod
    def from_dict(cls, d: dict[str, Any]) -> ParameterHasValue:
        return cls(
            d["condition"],
            d["dependee"],
            d["value"],
            [Condition.from_dict(cond_dict) for cond_dict in d["combined_with"]],
            d["check_dependee"],
            d["also"],
        )

    def to_dict(self) -> dict[str, Any]:
        return {
            "variant": Condition.Variant.HAS_VALUE.value,
            "condition": self.condition,
            "dependee": self.dependee,
            "value": self.value,
            "combined_with": [cond.to_dict() for cond in self.combined_with],
            "check_dependee": self.check_dependee,
            "also": self.also,
        }

also = also instance-attribute

check_dependee: bool = check_dependee instance-attribute

value: str = value instance-attribute

__init__(cond, dependee, value, combined_with=None, check_dependee=False, also=False)

Source code in src/library_analyzer/processing/api/_extract_dependencies.py
def __init__(
    self,
    cond: str,
    dependee: str,
    value: str,
    combined_with: list[Condition] | None = None,
    check_dependee: bool = False,
    also: bool = False,
) -> None:
    combined_with_list = combined_with if combined_with is not None else []
    super().__init__(cond, dependee, combined_with_list)
    self.check_dependee: bool = check_dependee
    self.value: str = value
    self.also = also

from_dict(d) classmethod

Source code in src/library_analyzer/processing/api/_extract_dependencies.py
@classmethod
def from_dict(cls, d: dict[str, Any]) -> ParameterHasValue:
    return cls(
        d["condition"],
        d["dependee"],
        d["value"],
        [Condition.from_dict(cond_dict) for cond_dict in d["combined_with"]],
        d["check_dependee"],
        d["also"],
    )

to_dict()

Source code in src/library_analyzer/processing/api/_extract_dependencies.py
def to_dict(self) -> dict[str, Any]:
    return {
        "variant": Condition.Variant.HAS_VALUE.value,
        "condition": self.condition,
        "dependee": self.dependee,
        "value": self.value,
        "combined_with": [cond.to_dict() for cond in self.combined_with],
        "check_dependee": self.check_dependee,
        "also": self.also,
    }