[#314] Format all files with black and isort

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-09-28 16:07:16 +04:00 committed by Vladimir
parent 26032a67ec
commit 147cac0ebc
46 changed files with 1506 additions and 1100 deletions

View file

@ -6,8 +6,8 @@ from .completion import NeofsAdmCompletion
from .config import NeofsAdmConfig
from .gendoc import NeofsAdmGenDoc
from .morph import NeofsAdmMorph
from .subnet import NeofsAdmMorphSubnet
from .storage_config import NeofsAdmStorageConfig
from .subnet import NeofsAdmMorphSubnet
from .version import NeofsAdmVersion
@ -23,14 +23,27 @@ class NeofsAdm:
storage_config: Optional[NeofsAdmStorageConfig] = None
version: Optional[NeofsAdmVersion] = None
def __init__(self, neofs_adm_exec_path: Optional[str] = None, config_file: Optional[str] = None, timeout: int = 30):
def __init__(
self,
neofs_adm_exec_path: Optional[str] = None,
config_file: Optional[str] = None,
timeout: int = 30,
):
self.config_file = config_file
self.neofs_adm_exec_path = neofs_adm_exec_path or NEOFS_ADM_EXEC
self.completion = NeofsAdmCompletion(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.completion = NeofsAdmCompletion(
self.neofs_adm_exec_path, timeout=timeout, config=config_file
)
self.config = NeofsAdmConfig(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.gendoc = NeofsAdmGenDoc(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.morph = NeofsAdmMorph(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.subnet = NeofsAdmMorphSubnet(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.storage_config = NeofsAdmStorageConfig(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.version = NeofsAdmVersion(self.neofs_adm_exec_path, timeout=timeout, config=config_file)
self.subnet = NeofsAdmMorphSubnet(
self.neofs_adm_exec_path, timeout=timeout, config=config_file
)
self.storage_config = NeofsAdmStorageConfig(
self.neofs_adm_exec_path, timeout=timeout, config=config_file
)
self.version = NeofsAdmVersion(
self.neofs_adm_exec_path, timeout=timeout, config=config_file
)

View file

@ -27,4 +27,4 @@ class NeofsAdmCompletion(NeofsCliCommand):
str: Command string
"""
return self._execute('completion ' + completion_type.value)
return self._execute("completion " + completion_type.value)

View file

@ -2,7 +2,7 @@ from enum import Enum
class CompletionType(Enum):
BASH = 'bash'
ZHS = 'zsh'
FISH = 'fish'
POWERSHELL = 'powershell'
BASH = "bash"
ZHS = "zsh"
FISH = "fish"
POWERSHELL = "powershell"

View file

@ -2,7 +2,7 @@ from cli_utils.cli_command import NeofsCliCommand
class NeofsAdmConfig(NeofsCliCommand):
def init(self, path: str = '~/.neofs/adm/config.yml') -> str:
def init(self, path: str = "~/.neofs/adm/config.yml") -> str:
"""Initialize basic neofs-adm configuration file.
Args:
@ -14,6 +14,6 @@ class NeofsAdmConfig(NeofsCliCommand):
"""
return self._execute(
'config init',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"config init",
**{param: value for param, value in locals().items() if param not in ["self"]},
)

View file

@ -4,7 +4,9 @@ from cli_utils.cli_command import NeofsCliCommand
class NeofsAdmGenDoc(NeofsCliCommand):
def get(self, doc_file: str, depth: int = 1, doc_type: str = 'md', extension: Optional[str] = None) -> str:
def get(
self, doc_file: str, depth: int = 1, doc_type: str = "md", extension: Optional[str] = None
) -> str:
"""Generate documentation for this command. If the template is not provided,
builtin cobra generator is used and each subcommand is placed in
a separate file in the same directory.
@ -29,6 +31,10 @@ class NeofsAdmGenDoc(NeofsCliCommand):
"""
return self._execute(
f'gendoc {doc_file}',
**{param: param_value for param, param_value in locals().items() if param not in ['self', 'doc_file']}
f"gendoc {doc_file}",
**{
param: value
for param, value in locals().items()
if param not in ["self", "doc_file"]
},
)

View file

@ -4,9 +4,16 @@ from cli_utils.cli_command import NeofsCliCommand
class NeofsAdmMorph(NeofsCliCommand):
def deposit_notary(self, rpc_endpoint: str, account: str, gas: str, storage_wallet: Optional[str] = None,
till: Optional[str] = None) -> str:
"""Deposit GAS for notary service.
def deposit_notary(
self,
rpc_endpoint: str,
account: str,
gas: str,
storage_wallet: Optional[str] = None,
till: Optional[str] = None,
) -> str:
"""
Deposit GAS for notary service.
Args:
account (str): wallet account address
@ -15,19 +22,24 @@ class NeofsAdmMorph(NeofsCliCommand):
storage_wallet (str): path to storage node wallet
till (str): notary deposit duration in blocks
Returns:
str: Command string
"""
return self._execute(
'morph deposit-notary',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph deposit-notary",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def dump_balances(self, rpc_endpoint: str, alphabet: Optional[str] = None, proxy: Optional[str] = None,
script_hash: Optional[str] = None, storage: Optional[str] = None) -> str:
"""Dump GAS balances
def dump_balances(
self,
rpc_endpoint: str,
alphabet: Optional[str] = None,
proxy: Optional[str] = None,
script_hash: Optional[str] = None,
storage: Optional[str] = None,
) -> str:
"""
Dump GAS balances.
Args:
alphabet (str): dump balances of alphabet contracts
@ -36,35 +48,38 @@ class NeofsAdmMorph(NeofsCliCommand):
script_hash (str): use script-hash format for addresses
storage (str): dump balances of storage nodes from the current netmap
Returns:
str: Command string
"""
return self._execute(
'morph dump-balances',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph dump-balances",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def dump_config(self, rpc_endpoint: str) -> str:
"""Section for morph network configuration commands.
"""
Dump NeoFS network config.
Args:
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph dump-config',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph dump-config",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def dump_containers(self, rpc_endpoint: str, cid: Optional[str] = None, container_contract: Optional[str] = None,
dump: Optional[str] = None) -> str:
"""Dump NeoFS containers to file.
def dump_containers(
self,
rpc_endpoint: str,
cid: Optional[str] = None,
container_contract: Optional[str] = None,
dump: Optional[str] = None,
) -> str:
"""
Dump NeoFS containers to file.
Args:
cid (str): containers to dump
@ -72,70 +87,73 @@ class NeofsAdmMorph(NeofsCliCommand):
dump (str): file where to save dumped containers
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph dump-containers',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph dump-containers",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def dump_hashes(self, rpc_endpoint: str) -> str:
"""Dump deployed contract hashes.
"""
Dump deployed contract hashes.
Args:
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph dump-hashes',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph dump-hashes",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def force_new_epoch(self, rpc_endpoint: Optional[str] = None, alphabet: Optional[str] = None) -> str:
"""Create new NeoFS epoch event in the side chain
def force_new_epoch(
self, rpc_endpoint: Optional[str] = None, alphabet: Optional[str] = None
) -> str:
"""
Create new NeoFS epoch event in the side chain
Args:
alphabet (str): path to alphabet wallets dir
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph force-new-epoch',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph force-new-epoch",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def generate_alphabet(self, rpc_endpoint: str, alphabet_wallets: str, size: int = 7) -> str:
"""Generate alphabet wallets for consensus nodes of the morph network
"""
Generate alphabet wallets for consensus nodes of the morph network.
Args:
alphabet_wallets (str): path to alphabet wallets dir
size (int): amount of alphabet wallets to generate (default 7)
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph generate-alphabet',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph generate-alphabet",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def generate_storage_wallet(self, rpc_endpoint: str, alphabet_wallets: str, storage_wallet: str,
initial_gas: Optional[str] = None) -> str:
"""Generate storage node wallet for the morph network
def generate_storage_wallet(
self,
rpc_endpoint: str,
alphabet_wallets: str,
storage_wallet: str,
initial_gas: Optional[str] = None,
) -> str:
"""
Generate storage node wallet for the morph network.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -143,21 +161,29 @@ class NeofsAdmMorph(NeofsCliCommand):
rpc_endpoint (str): N3 RPC node endpoint
storage_wallet (str): path to new storage node wallet
Returns:
str: Command string
"""
return self._execute(
'morph generate-storage-wallet',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph generate-storage-wallet",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def init(self, rpc_endpoint: str, alphabet_wallets: str, contracts: str, protocol: str,
container_alias_fee: int = 500, container_fee: int = 1000, epoch_duration: int = 240,
homomorphic_disabled: bool = False, local_dump: Optional[str] = None, max_object_size: int = 67108864
) -> str:
"""Section for morph network configuration commands.
def init(
self,
rpc_endpoint: str,
alphabet_wallets: str,
contracts: str,
protocol: str,
container_alias_fee: int = 500,
container_fee: int = 1000,
epoch_duration: int = 240,
homomorphic_disabled: bool = False,
local_dump: Optional[str] = None,
max_object_size: int = 67108864,
) -> str:
"""
Initialize side chain network with smart-contracts and network settings.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -172,19 +198,23 @@ class NeofsAdmMorph(NeofsCliCommand):
protocol (str): path to the consensus node configuration
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph init',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph init",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def refill_gas(self, rpc_endpoint: str, alphabet_wallets: str, storage_wallet: str, gas: Optional[str] = None
) -> str:
"""Refill GAS of storage node's wallet in the morph network
def refill_gas(
self,
rpc_endpoint: str,
alphabet_wallets: str,
storage_wallet: str,
gas: Optional[str] = None,
) -> str:
"""
Refill GAS of storage node's wallet in the morph network.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -192,18 +222,19 @@ class NeofsAdmMorph(NeofsCliCommand):
rpc_endpoint (str): N3 RPC node endpoint
storage_wallet (str): path to new storage node wallet
Returns:
str: Command string
"""
return self._execute(
'morph refill-gas',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph refill-gas",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def restore_containers(self, rpc_endpoint: str, alphabet_wallets: str, cid: str, dump: str) -> str:
"""Restore NeoFS containers from file.
def restore_containers(
self, rpc_endpoint: str, alphabet_wallets: str, cid: str, dump: str
) -> str:
"""
Restore NeoFS containers from file.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -211,19 +242,24 @@ class NeofsAdmMorph(NeofsCliCommand):
dump (str): file to restore containers from
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph restore-containers',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph restore-containers",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def set_policy(self, rpc_endpoint: str, alphabet_wallets: str, exec_fee_factor: Optional[int] = None,
storage_price: Optional[int] = None, fee_per_byte: Optional[int] = None) -> str:
"""Set global policy values
def set_policy(
self,
rpc_endpoint: str,
alphabet_wallets: str,
exec_fee_factor: Optional[int] = None,
storage_price: Optional[int] = None,
fee_per_byte: Optional[int] = None,
) -> str:
"""
Set global policy values.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -232,28 +268,30 @@ class NeofsAdmMorph(NeofsCliCommand):
fee_per_byte (int): FeePerByte=<n3>
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
non_param_attribute = ''
non_param_attribute = ""
if exec_fee_factor:
non_param_attribute += f'ExecFeeFactor={exec_fee_factor} '
non_param_attribute += f"ExecFeeFactor={exec_fee_factor} "
if storage_price:
non_param_attribute += f'StoragePrice={storage_price} '
non_param_attribute += f"StoragePrice={storage_price} "
if fee_per_byte:
non_param_attribute += f'FeePerByte={fee_per_byte} '
non_param_attribute += f"FeePerByte={fee_per_byte} "
return self._execute(
f'morph restore-containers {non_param_attribute}',
**{param: param_value for param, param_value in locals().items() if param not in [
'self', 'exec_fee_factor', 'storage_price', 'fee_per_byte'
]}
f"morph restore-containers {non_param_attribute}",
**{
param: value
for param, value in locals().items()
if param not in ["self", "exec_fee_factor", "storage_price", "fee_per_byte"]
},
)
def update_contracts(self, rpc_endpoint: str, alphabet_wallets: str, contracts: Optional[str] = None
) -> str:
"""Update NeoFS contracts.
def update_contracts(
self, rpc_endpoint: str, alphabet_wallets: str, contracts: Optional[str] = None
) -> str:
"""
Update NeoFS contracts.
Args:
alphabet_wallets (str): path to alphabet wallets dir
@ -261,12 +299,10 @@ class NeofsAdmMorph(NeofsCliCommand):
(default fetched from latest github release)
rpc_endpoint (str): N3 RPC node endpoint
Returns:
str: Command string
"""
return self._execute(
'morph update-contracts',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph update-contracts",
**{param: value for param, value in locals().items() if param not in ["self"]},
)

View file

@ -15,6 +15,6 @@ class NeofsAdmStorageConfig(NeofsCliCommand):
"""
return self._execute(
'storage-config',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"storage-config",
**{param: value for param, value in locals().items() if param not in ["self"]},
)

View file

@ -19,29 +19,31 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
"""
return self._execute(
'morph subnet create',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet create",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def get(self, rpc_endpoint: str, subnet: str) -> str:
"""Read information about the NeoFS subnet.
"""
Read information about the NeoFS subnet.
Args:
rpc_endpoint (str): N3 RPC node endpoint
subnet (str): ID of the subnet to read
Returns:
str: Command string
"""
return self._execute(
'morph subnet get',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet get",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def remove(self, rpc_endpoint: str, wallet: str, subnet: str, address: Optional[str] = None) -> str:
"""Remove NeoFS subnet.
def remove(
self, rpc_endpoint: str, wallet: str, subnet: str, address: Optional[str] = None
) -> str:
"""
Remove NeoFS subnet.
Args:
address (str): Address in the wallet, optional
@ -49,19 +51,26 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet remove',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet remove",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def admin_add(self, rpc_endpoint: str, wallet: str, admin: str, subnet: str, client: Optional[str] = None,
group: Optional[str] = None, address: Optional[str] = None) -> str:
"""Add admin to the NeoFS subnet.
def admin_add(
self,
rpc_endpoint: str,
wallet: str,
admin: str,
subnet: str,
client: Optional[str] = None,
group: Optional[str] = None,
address: Optional[str] = None,
) -> str:
"""
Add admin to the NeoFS subnet.
Args:
address (str): Address in the wallet, optional
@ -72,19 +81,25 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet admin add',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet admin add",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def admin_remove(self, rpc_endpoint: str, wallet: str, admin: str, subnet: str, client: Optional[str] = None,
address: Optional[str] = None) -> str:
"""Remove admin of the NeoFS subnet.
def admin_remove(
self,
rpc_endpoint: str,
wallet: str,
admin: str,
subnet: str,
client: Optional[str] = None,
address: Optional[str] = None,
) -> str:
"""
Remove admin of the NeoFS subnet.
Args:
address (str): Address in the wallet, optional
@ -94,19 +109,25 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet admin remove',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet admin remove",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def client_add(self, rpc_endpoint: str, wallet: str, subnet: str, client: Optional[str] = None,
group: Optional[str] = None, address: Optional[str] = None) -> str:
"""Add client to the NeoFS subnet.
def client_add(
self,
rpc_endpoint: str,
wallet: str,
subnet: str,
client: Optional[str] = None,
group: Optional[str] = None,
address: Optional[str] = None,
) -> str:
"""
Add client to the NeoFS subnet.
Args:
address (str): Address in the wallet, optional
@ -116,19 +137,25 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet client add',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet client add",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def client_remove(self, rpc_endpoint: str, wallet: str, client: str, group: str, subnet: str,
address: Optional[str] = None) -> str:
"""Remove client of the NeoFS subnet.
def client_remove(
self,
rpc_endpoint: str,
wallet: str,
client: str,
group: str,
subnet: str,
address: Optional[str] = None,
) -> str:
"""
Remove client of the NeoFS subnet.
Args:
address (str): Address in the wallet, optional
@ -138,18 +165,17 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet client remove',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet client remove",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def node_add(self, rpc_endpoint: str, wallet: str, node: str, subnet: str) -> str:
"""Add node to the NeoFS subnet.
"""
Add node to the NeoFS subnet.
Args:
node (str): Hex-encoded public key of the node
@ -157,18 +183,17 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet node add',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet node add",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def node_remove(self, rpc_endpoint: str, wallet: str, node: str, subnet: str) -> str:
"""Remove node from the NeoFS subnet.
"""
Remove node from the NeoFS subnet.
Args:
node (str): Hex-encoded public key of the node
@ -176,12 +201,10 @@ class NeofsAdmMorphSubnet(NeofsCliCommand):
subnet (str): ID of the subnet to read
wallet (str): Path to file with wallet
Returns:
str: Command string
"""
return self._execute(
'morph subnet node remove',
**{param: param_value for param, param_value in locals().items() if param not in ['self']}
"morph subnet node remove",
**{param: value for param, value in locals().items() if param not in ["self"]},
)

View file

@ -9,4 +9,4 @@ class NeofsAdmVersion(NeofsCliCommand):
str: Command string
"""
return self._execute('', version=True)
return self._execute("", version=True)