Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
6e50a624
Commit
6e50a624
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Add docstrings and type on properties and params
parent
db38ec77
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/core/net/node.py
+17
-6
17 additions, 6 deletions
src/cutecoin/core/net/node.py
src/cutecoin/models/network.py
+7
-2
7 additions, 2 deletions
src/cutecoin/models/network.py
with
24 additions
and
8 deletions
src/cutecoin/core/net/node.py
+
17
−
6
View file @
6e50a624
...
@@ -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
)])
This diff is collapsed.
Click to expand it.
src/cutecoin/models/network.py
+
7
−
2
View file @
6e50a624
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment