mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 03:09:52 +00:00
[style] update python style to conform to PEP 8 (#3951)
With the exception of line length set to 119 vs. 79. Add tests/ and tools/ to py-pretty-check.
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import io
|
||||
import struct
|
||||
|
||||
from binascii import hexlify
|
||||
@@ -60,7 +59,6 @@ class StatusValues(IntEnum):
|
||||
|
||||
|
||||
class TargetEid(object):
|
||||
|
||||
def __init__(self, eid):
|
||||
self._eid = eid
|
||||
|
||||
@@ -77,7 +75,6 @@ class TargetEid(object):
|
||||
|
||||
|
||||
class TargetEidFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
eid = bytearray(data.read(16))
|
||||
|
||||
@@ -85,7 +82,6 @@ class TargetEidFactory(object):
|
||||
|
||||
|
||||
class MacExtendedAddress(object):
|
||||
|
||||
def __init__(self, mac_address):
|
||||
self._mac_address = mac_address
|
||||
|
||||
@@ -98,11 +94,12 @@ class MacExtendedAddress(object):
|
||||
return self.mac_address == other.mac_address
|
||||
|
||||
def __repr__(self):
|
||||
return "MacExtendedAddress(mac_address={})".format(hexlify(self.mac_address))
|
||||
return "MacExtendedAddress(mac_address={})".format(
|
||||
hexlify(self.mac_address)
|
||||
)
|
||||
|
||||
|
||||
class MacExtendedAddressFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
mac_address = bytearray(data.read(8))
|
||||
|
||||
@@ -110,7 +107,6 @@ class MacExtendedAddressFactory(object):
|
||||
|
||||
|
||||
class Rloc16(object):
|
||||
|
||||
def __init__(self, rloc16):
|
||||
self._rloc16 = rloc16
|
||||
|
||||
@@ -127,7 +123,6 @@ class Rloc16(object):
|
||||
|
||||
|
||||
class Rloc16Factory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
rloc16 = struct.unpack(">H", data.read(2))[0]
|
||||
|
||||
@@ -135,7 +130,6 @@ class Rloc16Factory(object):
|
||||
|
||||
|
||||
class MlEid(object):
|
||||
|
||||
def __init__(self, ml_eid):
|
||||
self._ml_eid = ml_eid
|
||||
|
||||
@@ -152,7 +146,6 @@ class MlEid(object):
|
||||
|
||||
|
||||
class MlEidFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
ml_eid = bytearray(data.read(8))
|
||||
|
||||
@@ -160,7 +153,6 @@ class MlEidFactory(object):
|
||||
|
||||
|
||||
class Status(object):
|
||||
|
||||
def __init__(self, status):
|
||||
self._status = status
|
||||
|
||||
@@ -177,7 +169,6 @@ class Status(object):
|
||||
|
||||
|
||||
class StatusFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
status = StatusValues(ord(data.read(1)))
|
||||
|
||||
@@ -185,7 +176,6 @@ class StatusFactory(object):
|
||||
|
||||
|
||||
class TimeSinceLastTransaction(object):
|
||||
|
||||
def __init__(self, seconds):
|
||||
self._seconds = seconds
|
||||
|
||||
@@ -202,7 +192,6 @@ class TimeSinceLastTransaction(object):
|
||||
|
||||
|
||||
class TimeSinceLastTransactionFactory(object):
|
||||
|
||||
def parse(self, data, message_info):
|
||||
seconds = struct.unpack(">L", data.read(4))[0]
|
||||
|
||||
@@ -210,7 +199,6 @@ 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
|
||||
@@ -225,14 +213,18 @@ 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))
|
||||
return "RouterMask(id_sequence={}, router_id_mask={})".format(
|
||||
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]
|
||||
@@ -241,7 +233,6 @@ class RouterMaskFactory(object):
|
||||
|
||||
|
||||
class NdOption(object):
|
||||
|
||||
def __init__(self, options):
|
||||
self._options = options
|
||||
|
||||
@@ -254,11 +245,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)
|
||||
@@ -275,6 +267,7 @@ class NdDataFactory(object):
|
||||
def parse(self, data, message_info):
|
||||
raise NotImplementedError("TODO: Not implemented yet")
|
||||
|
||||
|
||||
class XtalAccuracy:
|
||||
# TODO: Not implemented yet
|
||||
|
||||
@@ -283,13 +276,11 @@ class XtalAccuracy:
|
||||
|
||||
|
||||
class XtalAccuracyFactory:
|
||||
|
||||
def parse(self, data, message_info):
|
||||
return XtalAccuracy()
|
||||
|
||||
|
||||
class ThreadNetworkData(object):
|
||||
|
||||
def __init__(self, tlvs):
|
||||
self._tlvs = tlvs
|
||||
|
||||
@@ -302,15 +293,15 @@ 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
|
||||
|
||||
def parse(self, data, message_info):
|
||||
tlvs = self._network_data_tlvs_factory.parse(data, message_info)
|
||||
return ThreadNetworkData(tlvs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user