openc2lib.types.base.array

 1from openc2lib.types.base.openc2_type import Openc2Type
 2
 3class Array(Openc2Type, list):
 4	""" OpenC2 Array
 5
 6		Implements OpenC2 Array:
 7		>An ordered list of unnamed fields with positionally-defined semantics. 
 8		Each field has a position, label, and type.
 9
10		However, position does not matter in this implementation.
11
12		Derived classes must provide a `fieldtypes` dictionary that associate each field name
13		to its class. This is strictly required in order to instantiate the object at
14		deserialization time. However, no check is performed when new items are inserted.
15	"""
16	fieldtypes = None
17	""" Field types
18
19		A `dictionary` which keys are field names and which values are the corresponding classes.
20		Must be provided by any derived class.
21	"""
22
23	def todict(self, e):
24		""" Converts to dictionary 
25		
26			It is used to convert this object to an intermediary representation during 
27			serialization. It takes an `Encoder` argument that is used to recursively
28			serialize inner data and structures (the `Encoder` provides standard methods
29			for converting base types to dictionaries).. 
30
31			:param e: The `Encoder` that is being used.
32			:return: A dictionary compliants to the Language Specification's serialization
33			rules.
34		"""
35		lis = []
36		for i in self:
37			lis.append = e.todict(i)
38		return lis
39
40	def fromdict(cls, dic, e):
41		""" !!! WARNING !!!
42			Currently not implemented because there are no examples of usage of this
43			type (only Array/net, which is not clear)
44		"""
45		raise Exception("Function not implemented")
class Array(openc2lib.types.base.openc2_type.Openc2Type, builtins.list):
 4class Array(Openc2Type, list):
 5	""" OpenC2 Array
 6
 7		Implements OpenC2 Array:
 8		>An ordered list of unnamed fields with positionally-defined semantics. 
 9		Each field has a position, label, and type.
10
11		However, position does not matter in this implementation.
12
13		Derived classes must provide a `fieldtypes` dictionary that associate each field name
14		to its class. This is strictly required in order to instantiate the object at
15		deserialization time. However, no check is performed when new items are inserted.
16	"""
17	fieldtypes = None
18	""" Field types
19
20		A `dictionary` which keys are field names and which values are the corresponding classes.
21		Must be provided by any derived class.
22	"""
23
24	def todict(self, e):
25		""" Converts to dictionary 
26		
27			It is used to convert this object to an intermediary representation during 
28			serialization. It takes an `Encoder` argument that is used to recursively
29			serialize inner data and structures (the `Encoder` provides standard methods
30			for converting base types to dictionaries).. 
31
32			:param e: The `Encoder` that is being used.
33			:return: A dictionary compliants to the Language Specification's serialization
34			rules.
35		"""
36		lis = []
37		for i in self:
38			lis.append = e.todict(i)
39		return lis
40
41	def fromdict(cls, dic, e):
42		""" !!! WARNING !!!
43			Currently not implemented because there are no examples of usage of this
44			type (only Array/net, which is not clear)
45		"""
46		raise Exception("Function not implemented")

OpenC2 Array

Implements OpenC2 Array:

An ordered list of unnamed fields with positionally-defined semantics. Each field has a position, label, and type.

However, position does not matter in this implementation.

Derived classes must provide a fieldtypes dictionary that associate each field name to its class. This is strictly required in order to instantiate the object at deserialization time. However, no check is performed when new items are inserted.

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.

def todict(self, e):
24	def todict(self, e):
25		""" Converts to dictionary 
26		
27			It is used to convert this object to an intermediary representation during 
28			serialization. It takes an `Encoder` argument that is used to recursively
29			serialize inner data and structures (the `Encoder` provides standard methods
30			for converting base types to dictionaries).. 
31
32			:param e: The `Encoder` that is being used.
33			:return: A dictionary compliants to the Language Specification's serialization
34			rules.
35		"""
36		lis = []
37		for i in self:
38			lis.append = e.todict(i)
39		return lis

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.

def fromdict(cls, dic, e):
41	def fromdict(cls, dic, e):
42		""" !!! WARNING !!!
43			Currently not implemented because there are no examples of usage of this
44			type (only Array/net, which is not clear)
45		"""
46		raise Exception("Function not implemented")

!!! WARNING !!! Currently not implemented because there are no examples of usage of this type (only Array/net, which is not clear)

Inherited Members
builtins.list
list
clear
copy
append
insert
extend
pop
remove
index
count
reverse
sort