Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit 79a6a098 authored by matograine's avatar matograine
Browse files

removing click usage

parent 594435a6
python>=3.7
duniterpy>=0.54.3
Pillow>=6.0.0
qrcode>=6.1
reportlab>=3.5.23
......@@ -16,7 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from silkaj.tools import message_exit
from click import command, option, pass_context, confirm
#from click import command, option, pass_context, confirm
from getpass import getpass
from pathlib import Path
from re import compile, search
......@@ -24,7 +24,7 @@ from duniterpy.key import SigningKey
from duniterpy.key.scrypt_params import ScryptParams
@pass_context
#@pass_context
def auth_method(ctx):
if ctx.obj["AUTH_SEED"]:
return auth_by_seed()
......@@ -36,8 +36,8 @@ def auth_method(ctx):
return auth_by_scrypt()
@command("authfile", help="Generate authentication file")
@option("--file", default="authfile", show_default=True, help="Path file")
#@command("authfile", help="Generate authentication file")
#@option("--file", default="authfile", show_default=True, help="Path file")
def generate_auth_file(file):
key = auth_method()
authfile = Path(file)
......@@ -58,7 +58,7 @@ def generate_auth_file(file):
)
@pass_context
#@pass_context
def auth_by_auth_file(ctx):
file = ctx.obj["AUTH_FILE_PATH"]
authfile = Path(file)
......@@ -87,7 +87,7 @@ def auth_by_seed():
message_exit(error)
"""
@pass_context
#@pass_context
def auth_by_scrypt(ctx):
salt = getpass("Please enter your Scrypt Salt (Secret identifier): ")
password = getpass("Please enter your Scrypt password (masked): ")
......
......@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, argument, echo, confirm
#from click import command, argument, echo, confirm
from time import time
from tabulate import tabulate
from duniterpy.api.bma import wot, blockchain
......@@ -29,8 +29,8 @@ from utils.silkaj.license import license_approval
from utils.silkaj.wot import is_member, get_informations_for_identity
@command("cert", help="Send certification")
@argument("id_to_certify")
#@command("cert", help="Send certification")
#@argument("id_to_certify")
@coroutine
async def send_certification(id_to_certify):
client = ClientInstance().client
......
......@@ -17,7 +17,7 @@ along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from click import group, help_option, version_option, option, pass_context
#from click import group, help_option, version_option, option, pass_context
from utils.silkaj.tx import send_transaction
from utils.silkaj.tx_history import transaction_history
......@@ -36,40 +36,40 @@ from utils.silkaj.license import license_command
from utils.silkaj.constants import SILKAJ_VERSION
@group()
@help_option("-h", "--help")
@version_option(SILKAJ_VERSION, "-v", "--version")
@option(
#@group()
#@help_option("-h", "--help")
#@version_option(SILKAJ_VERSION, "-v", "--version")
#@option(
"--peer",
"-p",
help="Default endpoint will reach Ğ1 currency with `https://g1.duniter.org` endpoint.\
Custom endpoint can be specified with `-p` option followed by <domain>:<port>",
)
@option(
#@option(
"--gtest", "-gt", is_flag=True, help="ĞTest: `https://g1-test.duniter.org` endpoint"
)
@option(
#@option(
"--auth-scrypt",
"--scrypt",
is_flag=True,
help="Scrypt authentication: default method",
)
@option("--nrp", help='Scrypt parameters: defaults N,r,p: "4096,16,1"')
@option(
#@option("--nrp", help='Scrypt parameters: defaults N,r,p: "4096,16,1"')
#@option(
"--auth-file",
"-af",
is_flag=True,
help="Authentication file. Defaults to: './authfile'",
)
@option(
#@option(
"--file",
default="authfile",
show_default=True,
help="Path file specification with '--auth-file'",
)
@option("--auth-seed", "--seed", is_flag=True, help="Seed hexadecimal authentication")
@option("--auth-wif", "--wif", is_flag=True, help="WIF and EWIF authentication methods")
@pass_context
#@option("--auth-seed", "--seed", is_flag=True, help="Seed hexadecimal authentication")
#@option("--auth-wif", "--wif", is_flag=True, help="WIF and EWIF authentication methods")
#@pass_context
def cli(ctx, peer, gtest, auth_scrypt, nrp, auth_file, file, auth_seed, auth_wif):
ctx.obj = dict()
ctx.ensure_object(dict)
......@@ -98,27 +98,27 @@ cli.add_command(send_transaction)
cli.add_command(received_sent_certifications)
@cli.command("about", help="Display program information")
#@cli.command("about", help="Display program information")
def about():
print(
"\
\n @@@@@@@@@@@@@\
\n @@@ @ @@@\
\n @@@ @@ @@@@@@ @@. Silkaj",
\n #@#@#@#@#@#@#@#@#@#@#@#@#@\
\n #@#@#@ #@ #@#@#@\
\n #@#@#@ #@#@ #@#@#@#@#@#@ #@#@. Silkaj",
SILKAJ_VERSION,
"\
\n @@ @@@ @@@@@@@@@@@ @@,\
\n @@ @@@ &@@@@@@@@@@@@@ @@@ Powerfull and lightweight command line client\
\n @@ @@@ @@@@@@@@@# @@@@ @@(\
\n @@ @@@@ @@@@@@@@@ @@@ @@ Built in Python for Duniter’s currencies: Ğ1 and Ğ1-Test\
\n @@ @@@ @@@@@@@@ @ @@@ @@\
\n @@ @@@ @@@@@@ @@@@ @@ @@ Authors: moul, tortue, jytou, cebash, cgeek\
\n @@ @@@@ @@@ @@@@@@@ @@ @@\
\n @@ @@@@* @@@@@@@@@ @# @@ Website: https://utils.silkaj.duniter.org\
\n @@ @@@@@ @@@@@@@@@@ @ ,@@\
\n @@ @@@@@ @@@@@@@@@@ @ ,@@ Repository: https://git.duniter.org/clients/python/silkaj\
\n @@@ @@@@@@@@@@@@ @ @@*\
\n @@@ @@@@@@@@ @ @@@ License: GNU AGPLv3\
\n @@@@ @@ @@@,\
\n @@@@@@@@@@@@@@@\n",
\n #@#@ #@#@#@ #@#@#@#@#@#@#@#@#@#@#@ #@#@,\
\n #@#@ #@#@#@ &#@#@#@#@#@#@#@#@#@#@#@#@#@ #@#@#@ Powerfull and lightweight command line client\
\n #@#@ #@#@#@ #@#@#@#@#@#@#@#@#@# #@#@#@#@ #@#@(\
\n #@#@ #@#@#@#@ #@#@#@#@#@#@#@#@#@ #@#@#@ #@#@ Built in Python for Duniter’s currencies: Ğ1 and Ğ1-Test\
\n #@#@ #@#@#@ #@#@#@#@#@#@#@#@ #@ #@#@#@ #@#@\
\n #@#@ #@#@#@ #@#@#@#@#@#@ #@#@#@#@ #@#@ #@#@ Authors: moul, tortue, jytou, cebash, cgeek\
\n #@#@ #@#@#@#@ #@#@#@ #@#@#@#@#@#@#@ #@#@ #@#@\
\n #@#@ #@#@#@#@* #@#@#@#@#@#@#@#@#@ #@# #@#@ Website: https://utils.silkaj.duniter.org\
\n #@#@ #@#@#@#@#@ #@#@#@#@#@#@#@#@#@#@ #@ ,#@#@\
\n #@#@ #@#@#@#@#@ #@#@#@#@#@#@#@#@#@#@ #@ ,#@#@ Repository: https://git.duniter.org/clients/python/silkaj\
\n #@#@#@ #@#@#@#@#@#@#@#@#@#@#@#@ #@ #@#@*\
\n #@#@#@ #@#@#@#@#@#@#@#@ #@ #@#@#@ License: GNU AGPLv3\
\n #@#@#@#@ #@#@ #@#@#@,\
\n #@#@#@#@#@#@#@#@#@#@#@#@#@#@#@\n",
)
......@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, option, argument, IntRange, get_terminal_size
#from click import command, option, argument, IntRange, get_terminal_size
from datetime import datetime
from os import system, popen
from collections import OrderedDict
......@@ -42,7 +42,7 @@ from utils.silkaj.tools import convert_time, message_exit, CurrencySymbol
from utils.silkaj.constants import ASYNC_SLEEP
@command("info", help="Display information about currency")
#@command("info", help="Display information about currency")
@coroutine
async def currency_info():
head_block = await HeadBlock().head_block
......@@ -90,7 +90,7 @@ def power(nbr, pow=0):
return "{0:.1f} × 10^{1}".format(nbr, pow)
@command(
#@command(
"diffi",
help="Display the current Proof of Work difficulty level to generate the next block",
)
......@@ -158,11 +158,11 @@ def get_network_sort_key(endpoint):
return tuple(t)
@command("net", help="Display network view")
@option(
#@command("net", help="Display network view")
#@option(
"--discover", "-d", is_flag=True, help="Discover the network (could take a while)"
)
@option(
#@option(
"--sort",
"-s",
default="block,member,diffi,uid",
......@@ -253,9 +253,9 @@ async def network_info(discover, sort):
print(tabulate(infos, headers="keys", tablefmt="orgtbl", stralign="center"))
@command("blocks", help="Display blocks: default: 0 for current window size")
@argument("number", default=0, type=IntRange(0, 5000))
@option(
#@command("blocks", help="Display blocks: default: 0 for current window size")
#@argument("number", default=0, type=IntRange(0, 5000))
#@option(
"--detailed",
"-d",
is_flag=True,
......@@ -347,7 +347,7 @@ async def list_blocks(number, detailed):
)
@command("argos", help="Display currency information formatted for Argos or BitBar")
#@command("argos", help="Display currency information formatted for Argos or BitBar")
@coroutine
async def argos_info():
head_block = await HeadBlock().head_block
......
......@@ -16,7 +16,7 @@ along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
import webbrowser
from click import command, echo_via_pager, confirm
#from click import command, echo_via_pager, confirm
def license_approval(currency):
......@@ -29,7 +29,7 @@ def license_approval(currency):
confirm("Do you approve Ğ1 license?", abort=True)
@command("license", help="Display Ğ1 license")
#@command("license", help="Display Ğ1 license")
def license_command():
display_license()
......
......@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, argument, pass_context
#from click import command, argument, pass_context
from utils.silkaj.network_tools import ClientInstance, HeadBlock
from utils.silkaj.tools import CurrencySymbol, message_exit, coroutine
......@@ -25,9 +25,9 @@ from duniterpy.api.bma import tx, blockchain
from duniterpy.documents.transaction import InputSource
@command("balance", help="Get wallet balance")
@argument("pubkeys", nargs=-1)
@pass_context
#@command("balance", help="Get wallet balance")
#@argument("pubkeys", nargs=-1)
#@pass_context
@coroutine
async def cmd_amount(ctx, pubkeys):
client = ClientInstance().client
......
......@@ -20,7 +20,7 @@ from ipaddress import ip_address
import socket
import logging
from sys import exit, stderr
from click import pass_context
#from click import pass_context
from asyncio import sleep
from duniterpy.api.client import Client
from duniterpy.api.bma import blockchain, network
......@@ -124,9 +124,9 @@ def singleton(class_):
return getinstance
#@singleton
##@singleton
class EndPoint(object):
# @pass_context
# #@pass_context
# def __init__(ctx, self):
def __init__(self):
ep = dict()
......@@ -151,7 +151,7 @@ class EndPoint(object):
"""
class EndPoint(object):
@pass_context
#@pass_context
def __init__(ctx, self):
ep = dict()
peer = ctx.obj["PEER"]
......@@ -171,7 +171,7 @@ class EndPoint(object):
self.BMA_ENDPOINT = " ".join([api, ep["domain"], ep["port"]])
"""
@singleton
#@singleton
class ClientInstance(object):
def __init__(self):
# self.client = Client(EndPoint().BMA_ENDPOINT)
......
......@@ -18,7 +18,7 @@ along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
from re import compile, search
import math
from time import sleep
from click import command, option, FloatRange
#from click import command, option, FloatRange
from tabulate import tabulate
from utils.silkaj.network_tools import ClientInstance, HeadBlock
......@@ -38,28 +38,30 @@ from duniterpy.api.bma.tx import process
from duniterpy.documents import BlockUID, Transaction
from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
@command("tx", help="Send transaction")
@option(
"""
#@command("tx", help="Send transaction")
#@option(
"--amount",
help="Quantitative value(s) : <value_1>:<value_2>:... If only one amount, it will be sent to all recipients.",
)
@option(
#@option(
"--amountUD",
help="Relative value(s) : <UDvalue_1>:<UDvalue_2>... If only one amount, it will be sent to all recipients.",
)
@option("--allSources", is_flag=True, help="Send all sources")
@option(
#@option("--allSources", is_flag=True, help="Send all sources")
#@option(
"--output",
required=True,
help="Pubkey(s)’ recipients + optional checksum: <pubkey>[!checksum]:[<pubkey>[!checksum]]",
)
@option("--comment", default="", help="Comment")
@option(
#@option("--comment", default="", help="Comment")
#@option(
"--outputBackChange",
help="Pubkey recipient to send the rest of the transaction: <pubkey[!checksum]>",
)
@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
#@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
"""
@coroutine
async def send_transaction(
amount, amountud, allsources, output, comment, outputbackchange, yes
......@@ -654,7 +656,7 @@ def checkComment(Comment):
if len(Comment) > 255:
message_exit("Error: Comment is too long")
regex = compile(
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\@\&\~\#\{\}\|\\\<\>\%\.]*$"
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\#@\&\~\#\{\}\|\\\<\>\%\.]*$"
)
if not search(regex, Comment):
message_exit("Error: the format of the comment is invalid")
......
......@@ -18,7 +18,7 @@ along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
from re import compile, search
import math
from time import sleep
from click import command, option, FloatRange
#from click import command, option, FloatRange
from tabulate import tabulate
from utils.silkaj.network_tools import ClientInstance, HeadBlock
......@@ -39,21 +39,21 @@ from duniterpy.documents import BlockUID, Transaction
from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
@command("tx", help="Send transaction")
@option("--amount", type=FloatRange(0.01), help="Quantitative value")
@option("--amountUD", type=float, help="Relative value")
@option("--allSources", is_flag=True, help="Send all sources")
@option(
#@command("tx", help="Send transaction")
#@option("--amount", type=FloatRange(0.01), help="Quantitative value")
#@option("--amountUD", type=float, help="Relative value")
#@option("--allSources", is_flag=True, help="Send all sources")
#@option(
"--output",
required=True,
help="Pubkey(s)’ recipients + optional checksum: <pubkey>[!checksum]:[<pubkey>[!checksum]]",
)
@option("--comment", default="", help="Comment")
@option(
#@option("--comment", default="", help="Comment")
#@option(
"--outputBackChange",
help="Pubkey recipient to send the rest of the transaction: <pubkey[!checksum]>",
)
@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
#@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
@coroutine
async def send_transaction(
amount, amountud, allsources, output, comment, outputbackchange, yes
......@@ -379,7 +379,7 @@ def checkComment(Comment):
if len(Comment) > 255:
message_exit("Error: Comment is too long")
regex = compile(
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\@\&\~\#\{\}\|\\\<\>\%\.]*$"
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\#@\&\~\#\{\}\|\\\<\>\%\.]*$"
)
if not search(regex, Comment):
message_exit("Error: the format of the comment is invalid")
......
......@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, argument, option, echo_via_pager, get_terminal_size
#from click import command, argument, option, echo_via_pager, get_terminal_size
from texttable import Texttable
from operator import itemgetter, neg, eq, ne
from time import time
......@@ -29,9 +29,9 @@ from utils.silkaj.money import get_amount_from_pubkey, amount_in_current_base, U
from utils.silkaj.tools import CurrencySymbol
@command("history", help="Display transaction history")
@argument("pubkey")
@option("--uids", "-u", is_flag=True, help="Display uids")
#@command("history", help="Display transaction history")
#@argument("pubkey")
#@option("--uids", "-u", is_flag=True, help="Display uids")
@coroutine
async def transaction_history(pubkey, uids):
if not check_public_key(pubkey, True):
......
......@@ -18,7 +18,7 @@ along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
from re import compile, search
import math
from time import sleep
from click import command, option, FloatRange
#from click import command, option, FloatRange
from tabulate import tabulate
from utils.silkaj.network_tools import ClientInstance, HeadBlock
......@@ -39,27 +39,27 @@ from duniterpy.documents import BlockUID, Transaction
from duniterpy.documents.transaction import InputSource, OutputSource, Unlock, SIGParameter
@command("tx", help="Send transaction")
@option(
#@command("tx", help="Send transaction")
#@option(
"--amount",
help="Quantitative value(s) : <value_1>:<value_2>:... If only one amount, it will be sent to all recipients.",
)
@option(
#@option(
"--amountUD",
help="Relative value(s) : <UDvalue_1>:<UDvalue_2>... If only one amount, it will be sent to all recipients.",
)
@option("--allSources", is_flag=True, help="Send all sources")
@option(
#@option("--allSources", is_flag=True, help="Send all sources")
#@option(
"--output",
required=True,
help="Pubkey(s)’ recipients + optional checksum: <pubkey>[!checksum]:[<pubkey>[!checksum]]",
)
@option("--comment", default="", help="Comment")
@option(
#@option("--comment", default="", help="Comment")
#@option(
"--outputBackChange",
help="Pubkey recipient to send the rest of the transaction: <pubkey[!checksum]>",
)
@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
#@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
@coroutine
async def send_transaction(
amount, amountud, allsources, output, comment, outputbackchange, yes
......@@ -516,7 +516,7 @@ def checkComment(Comment):
if len(Comment) > 255:
message_exit("Error: Comment is too long")
regex = compile(
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\@\&\~\#\{\}\|\\\<\>\%\.]*$"
"^[0-9a-zA-Z\ \-\_\:\/\;\*\[\]\(\)\?\!\^\+\=\#@\&\~\#\{\}\|\\\<\>\%\.]*$"
)
if not search(regex, Comment):
message_exit("Error: the format of the comment is invalid")
......
......@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with utils.silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from click import command, argument
##from click import command, argument
from time import time
from tabulate import tabulate
from collections import OrderedDict
......@@ -44,11 +44,11 @@ def get_sent_certifications(certs, time_first_block, params):
return sent, expire
@command(
#@command(
"wot",
help="Check received and sent certifications and consult the membership status of any given identity",
)
@argument("id")
#@argument("id")
@coroutine
async def received_sent_certifications(id):
"""
......@@ -155,8 +155,8 @@ def date_approximation(block_id, time_first_block, avgentime):
return time_first_block + block_id * avgentime
@command("id", help="Find corresponding identity or pubkey from pubkey or identity")
@argument("id_pubkey")
#@command("id", help="Find corresponding identity or pubkey from pubkey or identity")
#@argument("id_pubkey")
@coroutine
async def id_pubkey_correspondence(id_pubkey):
client = ClientInstance().client
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment