Skip to content
Snippets Groups Projects
Commit 6e50a624 authored by Vincent Texier's avatar Vincent Texier
Browse files

Add docstrings and type on properties and params

parent db38ec77
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,9 @@ from PyQt5.QtCore import QObject, pyqtSignal ...@@ -16,9 +16,9 @@ from PyQt5.QtCore import QObject, pyqtSignal
class Node(QObject): class Node(QObject):
''' """
classdocs classdocs
''' """
ONLINE = 1 ONLINE = 1
OFFLINE = 2 OFFLINE = 2
...@@ -27,10 +27,17 @@ class Node(QObject): ...@@ -27,10 +27,17 @@ class Node(QObject):
changed = pyqtSignal() changed = pyqtSignal()
def __init__(self, currency, endpoints, pubkey, block, state): def __init__(self, currency: str, endpoints: list, pubkey: str, block: int, state: int):
''' """
Constructor Constructor
''' :param str currency: Name of the currency
:param list endpoints: List of BMAEndpoint
:param str pubkey: Public key of the node owner
:param int block: Last block number
:param int state: State of the node
:return:
"""
super().__init__() super().__init__()
self._endpoints = endpoints self._endpoints = endpoints
self._pubkey = pubkey self._pubkey = pubkey
...@@ -91,7 +98,7 @@ class Node(QObject): ...@@ -91,7 +98,7 @@ class Node(QObject):
return self._pubkey return self._pubkey
@property @property
def endpoint(self): def endpoint(self) -> BMAEndpoint:
return next((e for e in self._endpoints if type(e) is BMAEndpoint)) return next((e for e in self._endpoints if type(e) is BMAEndpoint))
@property @property
...@@ -193,3 +200,7 @@ class Node(QObject): ...@@ -193,3 +200,7 @@ class Node(QObject):
time.sleep(interval) time.sleep(interval)
except RequestException as e: except RequestException as e:
self._state = Node.OFFLINE self._state = Node.OFFLINE
def __str__(self):
return ','.join([str(self.pubkey), str(self.endpoint.server), str(self.endpoint.port), str(self.block),
str(self.currency), str(self.state), str(self.neighbours)])
...@@ -94,7 +94,12 @@ class NetworkTableModel(QAbstractTableModel): ...@@ -94,7 +94,12 @@ class NetworkTableModel(QAbstractTableModel):
return self.column_types[section] return self.column_types[section]
def data_node(self, node): def data_node(self, node: Node) -> tuple:
"""
Return node data tuple
:param ..core.net.node.Node node: Network node
:return:
"""
try: try:
person = Person.lookup(node.pubkey, self.community) person = Person.lookup(node.pubkey, self.community)
uid = person.name uid = person.name
...@@ -112,7 +117,7 @@ class NetworkTableModel(QAbstractTableModel): ...@@ -112,7 +117,7 @@ class NetworkTableModel(QAbstractTableModel):
address = node.endpoint.ipv6 address = node.endpoint.ipv6
port = node.endpoint.port port = node.endpoint.port
return (node.pubkey, is_member, uid, address, port, node.block) return node.pubkey, is_member, uid, address, port, node.block
def data(self, index, role): def data(self, index, role):
row = index.row() row = index.row()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment