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
17fb11aa
Commit
17fb11aa
authored
2 years ago
by
matograine
Committed by
Moul
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[enh] wot: Migrate from tabulate to texttable (
#203
)
parent
2e12cdae
No related branches found
No related tags found
1 merge request
!199
#203: Harmonize tables style using Texttable
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/wot.py
+13
-11
13 additions, 11 deletions
silkaj/wot.py
tests/test_money.py
+1
-3
1 addition, 3 deletions
tests/test_money.py
with
14 additions
and
14 deletions
silkaj/wot.py
+
13
−
11
View file @
17fb11aa
...
@@ -20,14 +20,13 @@ from typing import Dict, List, Tuple
...
@@ -20,14 +20,13 @@ from typing import Dict, List, Tuple
import
click
import
click
from
duniterpy.api.bma
import
blockchain
,
wot
from
duniterpy.api.bma
import
blockchain
,
wot
from
pendulum
import
from_timestamp
,
now
from
pendulum
import
from_timestamp
,
now
from
tabulate
import
tabulate
from
silkaj
import
wot_tools
as
wt
from
silkaj
import
wot_tools
as
wt
from
silkaj.blockchain_tools
import
get_blockchain_parameters
from
silkaj.blockchain_tools
import
get_blockchain_parameters
from
silkaj.constants
import
DATE
from
silkaj.constants
import
DATE
from
silkaj.crypto_tools
import
is_pubkey_and_check
from
silkaj.crypto_tools
import
is_pubkey_and_check
from
silkaj.network_tools
import
client_instance
,
exit_on_http_error
from
silkaj.network_tools
import
client_instance
,
exit_on_http_error
from
silkaj.tui
import
gen_pubkey_checksum
from
silkaj.tui
import
Table
,
gen_pubkey_checksum
def
get_sent_certifications
(
def
get_sent_certifications
(
...
@@ -78,6 +77,8 @@ def received_sent_certifications(uid_pubkey: str) -> None:
...
@@ -78,6 +77,8 @@ def received_sent_certifications(uid_pubkey: str) -> None:
certifications
[
"
received_expire
"
]
=
[]
certifications
[
"
received_expire
"
]
=
[]
certifications
[
"
received
"
]
=
[]
certifications
[
"
received
"
]
=
[]
certifications
[
"
sent
"
]
=
[]
certifications
[
"
sent_expire
"
]
=
[]
for
cert
in
identity
[
"
others
"
]:
for
cert
in
identity
[
"
others
"
]:
certifications
[
"
received_expire
"
].
append
(
certifications
[
"
received_expire
"
].
append
(
expiration_date_from_block_id
(
expiration_date_from_block_id
(
...
@@ -92,15 +93,16 @@ def received_sent_certifications(uid_pubkey: str) -> None:
...
@@ -92,15 +93,16 @@ def received_sent_certifications(uid_pubkey: str) -> None:
certifications
[
"
sent_expire
"
],
certifications
[
"
sent_expire
"
],
)
=
get_sent_certifications
(
signed
,
time_first_block
,
params
)
)
=
get_sent_certifications
(
signed
,
time_first_block
,
params
)
nbr_sent_certs
=
len
(
certifications
[
"
sent
"
])
if
"
sent
"
in
certifications
else
0
nbr_sent_certs
=
len
(
certifications
[
"
sent
"
])
if
"
sent
"
in
certifications
else
0
table
=
tabulate
(
certifications
,
headers
=
"
keys
"
,
tablefmt
=
"
orgtbl
"
,
stralign
=
"
right
"
table
=
Table
(
style
=
"
columns
"
).
set_cols_align
([
"
r
"
,
"
r
"
,
"
r
"
,
"
r
"
])
)
table
.
fill_from_dict
(
certifications
)
print
(
print
(
f
'
{
identity
[
"
uid
"
]
}
(
{
gen_pubkey_checksum
(
pubkey
,
True
)
}
)
\
f
'
{
identity
[
"
uid
"
]
}
(
{
gen_pubkey_checksum
(
pubkey
,
True
)
}
)
\
from block #
{
identity
[
"
meta
"
][
"
timestamp
"
][
:
15
]
}
…
\n\
from block #
{
identity
[
"
meta
"
][
"
timestamp
"
][
:
15
]
}
…
\n\
received
{
len
(
certifications
[
"
received
"
])
}
and
\
received
{
len
(
certifications
[
"
received
"
])
}
and
sent
\
sent
{
nbr_sent_certs
}
/
{
params
[
"
sigStock
"
]
}
certifications:
\n\
{
nbr_sent_certs
}
/
{
params
[
"
sigStock
"
]
}
certifications:
\n\
{
table
}
\n\
{
table
.
draw
()
}
\n\
✔: Certification available to be written or already written into the blockchain
\n
'
✔: Certification available to be written or already written into the blockchain
\n
'
)
)
membership_status
(
certifications
,
pubkey
,
req
)
membership_status
(
certifications
,
pubkey
,
req
)
...
@@ -203,9 +205,9 @@ def choose_identity(pubkey_uid: str) -> Tuple[Dict, str, List]:
...
@@ -203,9 +205,9 @@ def choose_identity(pubkey_uid: str) -> Tuple[Dict, str, List]:
pubkey_index
=
0
pubkey_index
=
0
uid_index
=
0
uid_index
=
0
elif
identities
>
1
:
elif
identities
>
1
:
table
=
t
ab
ulate
(
identities_choices
,
headers
=
"
keys
"
,
tablefmt
=
"
orgtbl
"
)
table
=
T
ab
le
().
set_cols_dtype
([
"
t
"
,
"
t
"
,
"
t
"
,
"
t
"
]
)
click
.
echo
(
table
)
table
.
fill_from_dict
(
identities_choices
)
click
.
echo
(
table
.
draw
())
# Loop till the passed value is in identities_choices
# Loop till the passed value is in identities_choices
message
=
"
Which identity would you like to select (id)?
"
message
=
"
Which identity would you like to select (id)?
"
selected_id
=
None
selected_id
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/test_money.py
+
1
−
3
View file @
17fb11aa
...
@@ -19,9 +19,7 @@ from click.testing import CliRunner
...
@@ -19,9 +19,7 @@ from click.testing import CliRunner
from
silkaj.cli
import
cli
from
silkaj.cli
import
cli
from
silkaj.constants
import
FAILURE_EXIT_STATUS
from
silkaj.constants
import
FAILURE_EXIT_STATUS
from
silkaj.money
import
get_sources
from
silkaj.money
import
get_sources
from
silkaj.tui
import
gen_pubkey_checksum
# had to import from wot to prevent loop dependencies
from
silkaj.wot
import
gen_pubkey_checksum
def
test_get_sources
(
monkeypatch
):
def
test_get_sources
(
monkeypatch
):
...
...
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