예제 #1
0
파일: slots.py 프로젝트: sd-hd/snapcraft
    def validate(self) -> None:
        """Validate slot, raising exception on error."""

        if not self._slot_dict:
            raise SlotValidationError(slot_name=self.slot_name,
                                      message="slot has no defined attributes")

        if "interface" not in self._slot_dict:
            raise SlotValidationError(slot_name=self.slot_name,
                                      message="slot has no defined interface")
예제 #2
0
파일: slots.py 프로젝트: sd-hd/snapcraft
    def validate(self) -> None:
        """Validate dbus slot. Raise exception if invalid."""

        if not self.bus:
            raise SlotValidationError(
                slot_name=self.slot_name,
                message="valid `bus` is required for dbus slot",
            )

        if not self.name:
            raise SlotValidationError(
                slot_name=self.slot_name,
                message="valid `name` is required for dbus slot",
            )
예제 #3
0
파일: slots.py 프로젝트: sd-hd/snapcraft
    def validate(self) -> None:
        """Validate content slot, raising exception on error."""

        if not self.read and not self.write:
            raise SlotValidationError(
                slot_name=self.slot_name,
                message="`read` or `write` is required for slot",
            )
예제 #4
0
파일: slots.py 프로젝트: sd-hd/snapcraft
    def from_dict(cls, *, slot_dict: Dict[str, Any],
                  slot_name: str) -> "DbusSlot":
        """Instantiate DbusSlot from dict."""

        if slot_dict.get("interface") != "dbus":
            raise SlotValidationError(slot_name=slot_name,
                                      message="invalid interface for DbusSlot")

        if "bus" not in slot_dict:
            raise SlotValidationError(slot_name=slot_name,
                                      message="bus required for DbusSlot")

        if "name" not in slot_dict:
            raise SlotValidationError(slot_name=slot_name,
                                      message="name required for DbusSlot")

        return DbusSlot(slot_name=slot_name,
                        bus=slot_dict["bus"],
                        name=slot_dict["name"])