otupy.types.targets.properties.Properties

class Properties(args=[])

Bases: ArrayOf

OpenC2 Properties

Implements the properties target (Section 3.4.1.16). Data attribute associated with an Actuator: a list of names that uniquely identify its properties.

Methods

append

Append object to the end of the list.

clear

Remove all items from list.

copy

Return a shallow copy of the list.

count

Return number of occurrences of value.

extend

Extend list by appending elements from the iterable.

fromdict

Builds instance from dictionary

index

Return first index of value.

insert

Insert object before index.

pop

Remove and return item at index (default last).

remove

Remove first occurrence of value.

reverse

Reverse IN PLACE.

sort

Sort the list in ascending order and return None.

todict

Converts to dictionary

validate

Validate the list

Attributes

fieldtypes

Field types

__add__(item)

Return self+value.

__init__(args=[])

Array initialization

Arrays are initialized the same way as lists. They only take as input an interable (list, tuple, dict, or another Array/ArrayOf). Initialization with scalars is not allowed. In this case, a tuple must be used (mind to add the trailing comma even with a single value!)

Parameters:

args – The list, tuple, Array, ArrayOf used to initialize. May be empty.

__mul__(value, /)

Return self*value.

append(item)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

fieldtype

alias of str

fieldtypes = None

Field types

A dictionary which keys are field names and which values are the corresponding classes. Must be provided by any derived class.

classmethod fromdict(lis, e)

Builds instance from dictionary

It is used during deserialization to create an otupy instance from the text message. It takes an Encoder instance that is used to recursively build instances of the inner objects (the Encoder provides standard methods to create instances of base objects like strings, integers, boolean).

Parameters:
  • lis – The intermediary dictionary representation from which the object is built.

  • e – The :py:class:`~otupy.core.encoder.Encoder that is being used.

Returns:

An instance of this class initialized from the dictionary values.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, item)

Insert object before index.

pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

todict(e)

Converts to dictionary

It is used to convert this object to an intermediary representation during serialization. It takes an Encoder argument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..

Parameters:

e – The Encoder that is being used.

Returns:

A dictionary compliants to the Language Specification’s serialization rules.

validate(types: bool = True, num_min: int = 0, num_max: int = None)

Validate the list

Validation checks the types of the item and the size of the array. By properly combining the options, validation may include only a specific aspect. :param types: Set to True to validate the types of element in the list (Default: True). :param num_min: Set to the minimun number of elements; 0 to disable (Default: 0). :param num_max: Set to the maximun number of elements; None to disable (Default: None). :return: True if every required condition is satisfied. Otherwise, a ValueError Exception is raised.