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
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
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
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)
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)
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)
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
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
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
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
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