Ejemplo n.º 1
0
    def value(self, val):
        """
        Sets the option value.

        :param val: the value
        """
        if type(val) is str:
            val = bytearray(val, "utf-8")
        elif type(val) is int and byte_len(val) != 0:
            val = val
        elif type(val) is int and byte_len(val) == 0:
            val = bytearray()
        self._value = val
Ejemplo n.º 2
0
    def value(self, value):
        """

        :type value: String
        :param value:
        """
        if type(value) is str:
            value = bytearray(value, "utf-8")
        elif type(value) is int and byte_len(value) != 0:
            value = value
        elif type(value) is int and byte_len(value) == 0:
            value = 0
        self._value = value
Ejemplo n.º 3
0
    def value(self, value):
        """
        Set the value of the option.

        :param value: the option value
        """
        if type(value) is str:
            value = bytearray(value, "utf-8")
        elif type(value) is int and byte_len(value) != 0:
            value = value
        elif type(value) is int and byte_len(value) == 0:
            value = 0
        self._value = value
Ejemplo n.º 4
0
    def length(self):
        """
        Get the len of the option value

        :return: the len of the option value
        """
        if isinstance(self._value, int):
            return byte_len(self._value)
        return len(self._value)
Ejemplo n.º 5
0
    def length(self):
        """

        :rtype : Integer
        """
        if isinstance(self._value, int):
            return byte_len(self._value)
        if self._value is None:
            return 0
        return len(self._value)
Ejemplo n.º 6
0
    def length(self):
        """
        Return the value length

        :rtype : int
        """
        if isinstance(self._value, int):
            return byte_len(self._value)
        if self._value is None:
            return 0
        return len(self._value)
Ejemplo n.º 7
0
    def length(self):
        """
        Return the value length

        :rtype : int
        """
        if isinstance(self._value, int):
            return byte_len(self._value)
        if self._value is None:
            return 0
        return len(self._value)
Ejemplo n.º 8
0
    def value(self):
        """

        """
        if type(self._value) is None:
            self._value = bytearray()
        opt_type = defines.OptionRegistry.LIST[self._number].value_type
        if opt_type == defines.INTEGER:
            if byte_len(self._value) > 0:
                return int(self._value)
            else:
                return defines.OptionRegistry.LIST[self._number].default
        return self._value
Ejemplo n.º 9
0
    def value(self):
        """
        Return the option value.

        :return: the option value in the correct format depending on the option
        """
        if type(self._value) is None:
            self._value = bytes()
        opt_type = defines.OptionRegistry.LIST[self._number].value_type
        if opt_type == defines.INTEGER:
            if byte_len(self._value) > 0:
                return int(self._value)
            else:
                return defines.OptionRegistry.LIST[self._number].default
        return self._value
Ejemplo n.º 10
0
    def value(self):
        """
        Return the option value.

        :return: the option value in the correct format depending on the option
        """
        if type(self._value) is None:
            self._value = bytearray()
        opt_type = defines.OptionRegistry.LIST[self._number].value_type
        if opt_type == defines.INTEGER:
            if byte_len(self._value) > 0:
                return int(self._value)
            else:
                return defines.OptionRegistry.LIST[self._number].default
        return self._value
Ejemplo n.º 11
0
    def value(self):
        """
        Get the option value.


        :return: the option value as bytes
        """
        if type(self._value) is None:
            self._value = bytearray()
        name, opt_type, repeatable, defaults = defines.options[self._number]
        if opt_type == defines.INTEGER:
            if byte_len(self._value) > 0:
                return int(self._value)
            else:
                return defaults
        return self._value
Ejemplo n.º 12
0
    def value(self, value):
        """
        Set the value of the option.

        :param value: the option value
        """
        opt_type = defines.OptionRegistry.LIST[self._number].value_type
        if opt_type == defines.INTEGER:
            if type(value) is not int:
                value = int(value)
            if byte_len(value) == 0:
                value = 0
        elif opt_type == defines.STRING:
            if type(value) is not str:
                value = str(value)
        elif opt_type == defines.OPAQUE:
            if type(value) is bytes:
                pass
            else:
                if value is not None:
                    value = bytes(value, "utf-8")
        self._value = value