otupy.types.targets.features.Features
- class Features(feats=[])
Bases:
ArrayOfOpenC2 Features
Implements the features target (Section 3.4.1.5). Just defines an
ArrayOf:py:class`~otupy.types.data.Feature`.Methods
Append object to the end of the list.
Remove all items from list.
Return a shallow copy of the list.
Return number of occurrences of value.
Extend list by appending elements from the iterable.
Builds instance from dictionary
Return first index of value.
Insert object before index.
Remove and return item at index (default last).
Remove first occurrence of value.
Reverse IN PLACE.
Sort the list in ascending order and return None.
Converts to dictionary
Validate the list
Attributes
Field types
- __add__(item)
Return self+value.
- __init__(feats=[])
Array initialization
Arrays are initialized the same way as lists. They only take as input an interable (list,tuple,dict, or anotherArray/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,ArrayOfused 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.
- 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
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides 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.Encoderthat 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
Encoderargument that is used to recursively serialize inner data and structures (theEncoderprovides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat 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.