openc2lib.types.data.version

 1class Version(str):
 2	""" OpenC2 Version
 3
 4		Version of the OpenC2 protocol (Sec. 3.4.2.16). Currently a *<major>.<minor>* format is used.
 5	"""
 6	def __new__(cls, major, minor):
 7		""" Create `Version` instance
 8
 9			Create a Version instance from major and minor numbers, expressed as numbers.
10			:param major: Major number of OpenC2 version.
11			:param minor: Minor number of OpenC2 version.
12			:return: `Version` instance.
13		"""
14		vers = str(major) + '.' + str(minor)
15		instance = super().__new__(cls, vers)
16		return instance
17
18	def __init__(self, major, minor):
19		""" Initialize `Version` instance
20
21			Initialize with major and minor numbers.
22			:param major: Major number of OpenC2 version.
23			:param minor: Minor number of OpenC2 version.
24			:return: `Version` instance.
25		"""
26		self.major = major
27		self.minor = minor
28
29	@staticmethod
30	def fromstr(v):
31		""" Create `Version` instance
32
33			Create `Version` instance from string (in the *<major>.<minor>* notation.
34			:param v: Text string with the Version.
35			:return: `Version` instance.
36		"""
37		vers = v.split('.',2)
38		return Version(vers[0], vers[1])
39	
40	@classmethod
41	def fromdict(cls, vers, e=None):
42		""" Create `Version` instance
43
44			Create `Version` instance from string (in the *<major>.<minor>* notation.
45			This method is provided to deserialize an OpenC2 message according to the openc2lib approach.
46			This method should only be used internally the openc2lib.
47			:param vers: Text string with the Version.
48			:param e: `Encoder` instance to be used (only included to be compliance with the function footprint.
49			:return: `Version` instance.
50		"""
51		return Version.fromstr(vers)
class Version(builtins.str):
 3class Version(str):
 4	""" OpenC2 Version
 5
 6		Version of the OpenC2 protocol (Sec. 3.4.2.16). Currently a *<major>.<minor>* format is used.
 7	"""
 8	def __new__(cls, major, minor):
 9		""" Create `Version` instance
10
11			Create a Version instance from major and minor numbers, expressed as numbers.
12			:param major: Major number of OpenC2 version.
13			:param minor: Minor number of OpenC2 version.
14			:return: `Version` instance.
15		"""
16		vers = str(major) + '.' + str(minor)
17		instance = super().__new__(cls, vers)
18		return instance
19
20	def __init__(self, major, minor):
21		""" Initialize `Version` instance
22
23			Initialize with major and minor numbers.
24			:param major: Major number of OpenC2 version.
25			:param minor: Minor number of OpenC2 version.
26			:return: `Version` instance.
27		"""
28		self.major = major
29		self.minor = minor
30
31	@staticmethod
32	def fromstr(v):
33		""" Create `Version` instance
34
35			Create `Version` instance from string (in the *<major>.<minor>* notation.
36			:param v: Text string with the Version.
37			:return: `Version` instance.
38		"""
39		vers = v.split('.',2)
40		return Version(vers[0], vers[1])
41	
42	@classmethod
43	def fromdict(cls, vers, e=None):
44		""" Create `Version` instance
45
46			Create `Version` instance from string (in the *<major>.<minor>* notation.
47			This method is provided to deserialize an OpenC2 message according to the openc2lib approach.
48			This method should only be used internally the openc2lib.
49			:param vers: Text string with the Version.
50			:param e: `Encoder` instance to be used (only included to be compliance with the function footprint.
51			:return: `Version` instance.
52		"""
53		return Version.fromstr(vers)

OpenC2 Version

Version of the OpenC2 protocol (Sec. 3.4.2.16). Currently a . format is used.

Version(major, minor)
20	def __init__(self, major, minor):
21		""" Initialize `Version` instance
22
23			Initialize with major and minor numbers.
24			:param major: Major number of OpenC2 version.
25			:param minor: Minor number of OpenC2 version.
26			:return: `Version` instance.
27		"""
28		self.major = major
29		self.minor = minor

Initialize Version instance

Initialize with major and minor numbers.

Parameters
  • major: Major number of OpenC2 version.
  • minor: Minor number of OpenC2 version.
Returns

Version instance.

major
minor
@staticmethod
def fromstr(v):
31	@staticmethod
32	def fromstr(v):
33		""" Create `Version` instance
34
35			Create `Version` instance from string (in the *<major>.<minor>* notation.
36			:param v: Text string with the Version.
37			:return: `Version` instance.
38		"""
39		vers = v.split('.',2)
40		return Version(vers[0], vers[1])

Create Version instance

Create Version instance from string (in the . notation.

Parameters
  • v: Text string with the Version.
Returns

Version instance.

@classmethod
def fromdict(cls, vers, e=None):
42	@classmethod
43	def fromdict(cls, vers, e=None):
44		""" Create `Version` instance
45
46			Create `Version` instance from string (in the *<major>.<minor>* notation.
47			This method is provided to deserialize an OpenC2 message according to the openc2lib approach.
48			This method should only be used internally the openc2lib.
49			:param vers: Text string with the Version.
50			:param e: `Encoder` instance to be used (only included to be compliance with the function footprint.
51			:return: `Version` instance.
52		"""
53		return Version.fromstr(vers)

Create Version instance

Create Version instance from string (in the . notation. This method is provided to deserialize an OpenC2 message according to the openc2lib approach. This method should only be used internally the openc2lib.

Parameters
  • vers: Text string with the Version.
  • e: Encoder instance to be used (only included to be compliance with the function footprint.
Returns

Version instance.

Inherited Members
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans