Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
06ded9b3
Commit
06ded9b3
authored
2 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mypy]
#163
: identity_of(): always return a value
Move exception handling outside
parent
3f79a760
No related branches found
No related tags found
1 merge request
!214
#163: Introduce mypy
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/commands.py
+6
-2
6 additions, 2 deletions
silkaj/commands.py
silkaj/wot_tools.py
+4
-6
4 additions, 6 deletions
silkaj/wot_tools.py
with
10 additions
and
8 deletions
silkaj/commands.py
+
6
−
2
View file @
06ded9b3
...
@@ -17,6 +17,7 @@ from collections import OrderedDict
...
@@ -17,6 +17,7 @@ from collections import OrderedDict
from
operator
import
itemgetter
from
operator
import
itemgetter
from
os
import
system
from
os
import
system
from
typing
import
Dict
,
List
,
Tuple
from
typing
import
Dict
,
List
,
Tuple
from
urllib.error
import
HTTPError
import
jsonschema
import
jsonschema
from
click
import
IntRange
,
argument
,
command
,
option
from
click
import
IntRange
,
argument
,
command
,
option
...
@@ -151,14 +152,17 @@ def list_blocks(number: int, detailed: bool) -> None:
...
@@ -151,14 +152,17 @@ def list_blocks(number: int, detailed: bool) -> None:
issuers
.
append
(
issuer
)
issuers
.
append
(
issuer
)
for
pubkey
in
issuers_dict
.
keys
():
for
pubkey
in
issuers_dict
.
keys
():
issuer
=
issuers_dict
[
pubkey
]
issuer
=
issuers_dict
[
pubkey
]
idty
=
identity_of
(
issuer
[
"
pubkey
"
])
try
:
idty
=
identity_of
(
issuer
[
"
pubkey
"
])
except
HTTPError
:
idty
=
None
for
issuer2
in
issuers
:
for
issuer2
in
issuers
:
if
(
if
(
issuer2
.
get
(
"
pubkey
"
)
is
not
None
issuer2
.
get
(
"
pubkey
"
)
is
not
None
and
issuer
.
get
(
"
pubkey
"
)
is
not
None
and
issuer
.
get
(
"
pubkey
"
)
is
not
None
and
issuer2
[
"
pubkey
"
]
==
issuer
[
"
pubkey
"
]
and
issuer2
[
"
pubkey
"
]
==
issuer
[
"
pubkey
"
]
):
):
issuer2
[
"
uid
"
]
=
idty
[
"
uid
"
]
issuer2
[
"
uid
"
]
=
idty
[
"
uid
"
]
if
idty
else
None
issuer2
.
pop
(
"
pubkey
"
)
issuer2
.
pop
(
"
pubkey
"
)
header
=
(
header
=
(
f
"
Last
{
number
}
blocks from n°
{
current_nbr
-
number
+
1
}
to n°
{
current_nbr
}
"
f
"
Last
{
number
}
blocks from n°
{
current_nbr
-
number
+
1
}
to n°
{
current_nbr
}
"
...
...
This diff is collapsed.
Click to expand it.
silkaj/wot_tools.py
+
4
−
6
View file @
06ded9b3
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
from
typing
import
Dict
,
List
,
Optional
from
typing
import
Dict
,
List
,
Optional
from
urllib.error
import
HTTPError
from
duniterpy.api.bma
import
wot
from
duniterpy.api.bma
import
wot
...
@@ -27,10 +28,7 @@ def identity_of(pubkey_uid: str) -> Dict:
...
@@ -27,10 +28,7 @@ def identity_of(pubkey_uid: str) -> Dict:
Able to know if an identity is member or not
Able to know if an identity is member or not
"""
"""
client
=
client_instance
()
client
=
client_instance
()
try
:
return
client
(
wot
.
identity_of
,
pubkey_uid
)
return
client
(
wot
.
identity_of
,
pubkey_uid
)
except
ValueError
:
pass
def
is_member
(
pubkey_uid
:
str
)
->
Optional
[
Dict
]:
def
is_member
(
pubkey_uid
:
str
)
->
Optional
[
Dict
]:
...
@@ -40,7 +38,7 @@ def is_member(pubkey_uid: str) -> Optional[Dict]:
...
@@ -40,7 +38,7 @@ def is_member(pubkey_uid: str) -> Optional[Dict]:
"""
"""
try
:
try
:
return
identity_of
(
pubkey_uid
)
return
identity_of
(
pubkey_uid
)
except
Exception
:
except
HTTPError
:
return
None
return
None
...
@@ -67,6 +65,6 @@ def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List:
...
@@ -67,6 +65,6 @@ def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List:
for
pubkey
in
uniq_pubkeys
:
for
pubkey
in
uniq_pubkeys
:
try
:
try
:
identities
.
append
(
identity_of
(
pubkey
))
identities
.
append
(
identity_of
(
pubkey
))
except
Exception
:
except
HTTPError
:
pass
pass
return
identities
return
identities
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