示例#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"])