Skip to content
Snippets Groups Projects
Commit 9cf94da5 authored by matograine's avatar matograine
Browse files

[mod] #344 use pendulum in silkaj.wot

  * change alignment for wot table for easy date reading
parent 7aec21f0
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. ...@@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
""" """
import click import click
from pendulum import from_timestamp
from time import time from time import time
from tabulate import tabulate from tabulate import tabulate
from collections import OrderedDict from collections import OrderedDict
...@@ -26,9 +27,9 @@ from duniterpy.api.errors import DuniterError ...@@ -26,9 +27,9 @@ from duniterpy.api.errors import DuniterError
from silkaj.network_tools import ClientInstance from silkaj.network_tools import ClientInstance
from silkaj.crypto_tools import is_pubkey_and_check from silkaj.crypto_tools import is_pubkey_and_check
from silkaj.tools import message_exit, coroutine from silkaj.tools import message_exit, coroutine
from silkaj.tui import convert_time, display_pubkey_and_checksum from silkaj.tui import display_pubkey_and_checksum
from silkaj.blockchain_tools import BlockchainParams from silkaj.blockchain_tools import BlockchainParams
from silkaj.constants import ASYNC_SLEEP from silkaj.constants import ASYNC_SLEEP, DATE
def get_sent_certifications(signed, time_first_block, params): def get_sent_certifications(signed, time_first_block, params):
...@@ -98,7 +99,7 @@ async def received_sent_certifications(uid_pubkey): ...@@ -98,7 +99,7 @@ async def received_sent_certifications(uid_pubkey):
certifications, certifications,
headers="keys", headers="keys",
tablefmt="orgtbl", tablefmt="orgtbl",
stralign="center", stralign="right",
), ),
"✔: Certification available to be written or already written into the blockchain", "✔: Certification available to be written or already written into the blockchain",
) )
...@@ -128,29 +129,25 @@ async def membership_status(certifications, pubkey, req): ...@@ -128,29 +129,25 @@ async def membership_status(certifications, pubkey, req):
member = True member = True
print("member:", member) print("member:", member)
if req["revoked"]: if req["revoked"]:
print( revoke_date = from_timestamp(req["revoked_on"]).format(DATE)
"revoked:", print(f"revoked: {req['revoked']}\nrevoked on: {revoke_date}")
req["revoked"],
"\nrevoked on:",
convert_time(req["revoked_on"], "date") + "\n",
)
if not member and req["wasMember"]: if not member and req["wasMember"]:
print("expired:", req["expired"], "\nwasMember:", req["wasMember"]) print("expired:", req["expired"], "\nwasMember:", req["wasMember"])
elif member: elif member:
expir_ts = time() + req["membershipExpiresIn"]
print( print(
"Membership document expiration: " "Membership document expiration: " + from_timestamp(expir_ts).format(DATE)
+ convert_time(time() + req["membershipExpiresIn"], "date")
) )
print("Sentry:", req["isSentry"]) print("Sentry:", req["isSentry"])
print("outdistanced:", req["outdistanced"]) print("outdistanced:", req["outdistanced"])
def expiration_date_from_block_id(block_id, time_first_block, params): def expiration_date_from_block_id(block_id, time_first_block, params):
return convert_time( expir_timestamp = (
date_approximation(block_id, time_first_block, params["avgGenTime"]) date_approximation(block_id, time_first_block, params["avgGenTime"])
+ params["sigValidity"], + params["sigValidity"]
"date",
) )
return from_timestamp(expir_timestamp).format(DATE)
def date_approximation(block_id, time_first_block, avgentime): def date_approximation(block_id, time_first_block, avgentime):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment