mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 00:49:53 +00:00
[style] apply google python style guide (#4501)
This commit applies and enforces Google's python style for tests.
This commit is contained in:
@@ -59,6 +59,7 @@ class StatusValues(IntEnum):
|
||||
|
||||
|
||||
class TargetEid(object):
|
||||
|
||||
def __init__(self, eid):
|
||||
self._eid = eid
|
||||
|
||||
@@ -75,6 +76,7 @@ class TargetEid(object):
|
||||
|
||||
|
||||
class TargetEidFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
eid = bytearray(data.read(16))
|
||||
|
||||
@@ -82,6 +84,7 @@ class TargetEidFactory(object):
|
||||
|
||||
|
||||
class MacExtendedAddress(object):
|
||||
|
||||
def __init__(self, mac_address):
|
||||
self._mac_address = mac_address
|
||||
|
||||
@@ -95,11 +98,11 @@ class MacExtendedAddress(object):
|
||||
|
||||
def __repr__(self):
|
||||
return "MacExtendedAddress(mac_address={})".format(
|
||||
hexlify(self.mac_address)
|
||||
)
|
||||
hexlify(self.mac_address))
|
||||
|
||||
|
||||
class MacExtendedAddressFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
mac_address = bytearray(data.read(8))
|
||||
|
||||
@@ -107,6 +110,7 @@ class MacExtendedAddressFactory(object):
|
||||
|
||||
|
||||
class Rloc16(object):
|
||||
|
||||
def __init__(self, rloc16):
|
||||
self._rloc16 = rloc16
|
||||
|
||||
@@ -123,6 +127,7 @@ class Rloc16(object):
|
||||
|
||||
|
||||
class Rloc16Factory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
rloc16 = struct.unpack(">H", data.read(2))[0]
|
||||
|
||||
@@ -130,6 +135,7 @@ class Rloc16Factory(object):
|
||||
|
||||
|
||||
class MlEid(object):
|
||||
|
||||
def __init__(self, ml_eid):
|
||||
self._ml_eid = ml_eid
|
||||
|
||||
@@ -146,6 +152,7 @@ class MlEid(object):
|
||||
|
||||
|
||||
class MlEidFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
ml_eid = bytearray(data.read(8))
|
||||
|
||||
@@ -153,6 +160,7 @@ class MlEidFactory(object):
|
||||
|
||||
|
||||
class Status(object):
|
||||
|
||||
def __init__(self, status):
|
||||
self._status = status
|
||||
|
||||
@@ -169,6 +177,7 @@ class Status(object):
|
||||
|
||||
|
||||
class StatusFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
status = StatusValues(ord(data.read(1)))
|
||||
|
||||
@@ -176,6 +185,7 @@ class StatusFactory(object):
|
||||
|
||||
|
||||
class TimeSinceLastTransaction(object):
|
||||
|
||||
def __init__(self, seconds):
|
||||
self._seconds = seconds
|
||||
|
||||
@@ -192,6 +202,7 @@ class TimeSinceLastTransaction(object):
|
||||
|
||||
|
||||
class TimeSinceLastTransactionFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
seconds = struct.unpack(">L", data.read(4))[0]
|
||||
|
||||
@@ -199,6 +210,7 @@ class TimeSinceLastTransactionFactory(object):
|
||||
|
||||
|
||||
class RouterMask(object):
|
||||
|
||||
def __init__(self, id_sequence, router_id_mask):
|
||||
self._id_sequence = id_sequence
|
||||
self._router_id_mask = router_id_mask
|
||||
@@ -213,18 +225,16 @@ class RouterMask(object):
|
||||
|
||||
def __eq__(self, other):
|
||||
common.expect_the_same_class(self, other)
|
||||
return (
|
||||
self.id_sequence == other.id_sequence
|
||||
and self.router_id_mask == other.router_id_mask
|
||||
)
|
||||
return (self.id_sequence == other.id_sequence and
|
||||
self.router_id_mask == other.router_id_mask)
|
||||
|
||||
def __repr__(self):
|
||||
return "RouterMask(id_sequence={}, router_id_mask={})".format(
|
||||
self.id_sequence, hex(self.router_id_mask)
|
||||
)
|
||||
self.id_sequence, hex(self.router_id_mask))
|
||||
|
||||
|
||||
class RouterMaskFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
id_sequence = ord(data.read(1))
|
||||
router_id_mask = struct.unpack(">Q", data.read(8))[0]
|
||||
@@ -233,6 +243,7 @@ class RouterMaskFactory(object):
|
||||
|
||||
|
||||
class NdOption(object):
|
||||
|
||||
def __init__(self, options):
|
||||
self._options = options
|
||||
|
||||
@@ -245,12 +256,12 @@ class NdOption(object):
|
||||
return self.options == other.options
|
||||
|
||||
def __repr__(self):
|
||||
return "NdOption(options=[{}])".format(
|
||||
", ".join([str(opt) for opt in self.options])
|
||||
)
|
||||
return "NdOption(options=[{}])".format(", ".join(
|
||||
[str(opt) for opt in self.options]))
|
||||
|
||||
|
||||
class NdOptionFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
options = [opt for opt in bytearray(data.read())]
|
||||
return NdOption(options)
|
||||
@@ -276,11 +287,13 @@ class XtalAccuracy:
|
||||
|
||||
|
||||
class XtalAccuracyFactory:
|
||||
|
||||
def parse(self, data, message_info):
|
||||
return XtalAccuracy()
|
||||
|
||||
|
||||
class ThreadNetworkData(object):
|
||||
|
||||
def __init__(self, tlvs):
|
||||
self._tlvs = tlvs
|
||||
|
||||
@@ -293,12 +306,12 @@ class ThreadNetworkData(object):
|
||||
return self.tlvs == other.tlvs
|
||||
|
||||
def __repr__(self):
|
||||
return "ThreadNetworkData(tlvs=[{}])".format(
|
||||
", ".join([str(tlv) for tlv in self.tlvs])
|
||||
)
|
||||
return "ThreadNetworkData(tlvs=[{}])".format(", ".join(
|
||||
[str(tlv) for tlv in self.tlvs]))
|
||||
|
||||
|
||||
class ThreadNetworkDataFactory(object):
|
||||
|
||||
def __init__(self, network_data_tlvs_factory):
|
||||
self._network_data_tlvs_factory = network_data_tlvs_factory
|
||||
|
||||
|
||||
Reference in New Issue
Block a user