arguments Module

Argument Class

class oscpython.arguments.Argument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: object

Base class for OSC arguments

tag: ClassVar[str]

The OSC type tag for the argument

struct_fmt: ClassVar[str]

Format string used by struct

py_type: ClassVar[type]

The matching Python type for the argument

value: Optional[Any] = None

The argument value

index: int = -1

The argument index within its parent oscpython.messages.Message

classmethod get_argument_for_value(value: Any)oscpython.arguments.Argument[source]

Get an Argument subclass to handle the given value

Raises

ArgumentTypeError – If the given type is not supported

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

validate_value()[source]

Perform value checks (used by subclasses)

Raises

ArgumentValueError – If the value is invalid

get_struct_fmt()str[source]

Return the format string for struct.pack() matching the current value

This should normally be struct_fmt, but certain types (like str) must be able to override with the appropriate length

pack()oscpython.common.StructPacking[source]

Create a StructPacking for the argument

build_packet()bytes[source]

Pack the argument to bytes formatted for an OSC packet

get_pack_value()Optional[Tuple[Any]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

classmethod parse(data: bytes)Tuple[oscpython.arguments.Argument, bytes][source]

Parse OSC-formatted data and create an Argument

Returns a tuple of:
Argument

Argument containing the parsed value

bytes

Any remaining bytes after the argument data

Int32Argument Class

class oscpython.arguments.Int32Argument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

16-bit integer argument

py_type

alias of int

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

validate_value()[source]

Perform value checks (used by subclasses)

Raises

ArgumentValueError – If the value is invalid

Float32Argument Class

class oscpython.arguments.Float32Argument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

32-bit float argument

py_type

alias of float

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

StringArgument Class

class oscpython.arguments.StringArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

String argument

py_type

alias of str

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[str]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

get_struct_fmt()str[source]

Return the format string for struct.pack() matching the current value

This should normally be struct_fmt, but certain types (like str) must be able to override with the appropriate length

classmethod parse(data: bytes)Tuple[oscpython.arguments.StringArgument, bytes][source]

Parse OSC-formatted data and create an Argument

Returns a tuple of:
Argument

Argument containing the parsed value

bytes

Any remaining bytes after the argument data

BlobArgument Class

class oscpython.arguments.BlobArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

Blob (bytes) argument

py_type

alias of bytes

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

validate_value()[source]

Perform value checks (used by subclasses)

Raises

ArgumentValueError – If the value is invalid

get_pack_value()Optional[Tuple[int, bytes]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

get_struct_fmt()str[source]

Return the format string for struct.pack() matching the current value

This should normally be struct_fmt, but certain types (like str) must be able to override with the appropriate length

classmethod parse(data: bytes)Tuple[oscpython.arguments.BlobArgument, bytes][source]

Parse OSC-formatted data and create an Argument

Returns a tuple of:
Argument

Argument containing the parsed value

bytes

Any remaining bytes after the argument data

Int64Argument Class

class oscpython.arguments.Int64Argument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Int32Argument

64-bit integer argument

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

validate_value()[source]

Perform value checks (used by subclasses)

Raises

ArgumentValueError – If the value is invalid

TimeTagArgument Class

class oscpython.arguments.TimeTagArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

TimeTag argument (see TimeTag)

py_type

alias of oscpython.common.TimeTag

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[int]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

Float64Argument Class

class oscpython.arguments.Float64Argument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Float32Argument

64-bit float argument

CharArgument Class

class oscpython.arguments.CharArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

Char argument (a single ascii character)

py_type

alias of str

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[bytes]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

validate_value()[source]

Perform value checks (used by subclasses)

Raises

ArgumentValueError – If the value is invalid

RGBArgument Class

class oscpython.arguments.RGBArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

RGBA color argument (see ColorRGBA)

py_type

alias of oscpython.common.ColorRGBA

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[int]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

MidiArgument Class

class oscpython.arguments.MidiArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

A 4-byte MIDI message

py_type

alias of oscpython.common.MidiMessage

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[int]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

TrueArgument Class

class oscpython.arguments.TrueArgument(value: Optional[Any] = True, index: int = - 1)[source]

Bases: oscpython.arguments.BoolArgument

Argument for True

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

FalseArgument Class

class oscpython.arguments.FalseArgument(value: Optional[Any] = False, index: int = - 1)[source]

Bases: oscpython.arguments.BoolArgument

Argument for False

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

NilArgument Class

class oscpython.arguments.NilArgument(value: Optional[Any] = None, index: int = - 1)[source]

Bases: oscpython.arguments.Argument

Nil (None) argument

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[Any]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

InfinitumArgument Class

class oscpython.arguments.InfinitumArgument(value: Optional[Any] = <factory>, index: int = -1)[source]

Bases: oscpython.arguments.Argument

Infinitum argument (see Infinitum)

py_type

alias of oscpython.common.Infinitum

classmethod works_for_value(value: Any)bool[source]

Return True if the class is able to handle the given value and its type

get_pack_value()Optional[Tuple[Any]][source]

Get the value(s) to be packed using struct.pack()

Returns None if no value is associated with the argument, otherwise a tuple (even if there is only one item)

Exceptions

class oscpython.arguments.ArgumentError(value: Any, msg: Optional[str] = None)[source]

Bases: Exception

class oscpython.arguments.ArgumentTypeError(value: Any, msg: Optional[str] = None)[source]

Bases: oscpython.arguments.ArgumentError

class oscpython.arguments.ArgumentValueError(value: Any, msg: Optional[str] = None)[source]

Bases: oscpython.arguments.ArgumentError