frostfs-testcases/robot/resources/lib/python_keywords/data_formatters.py
Elizaveta Chichindaeva da9b723498 [#246] Get pubkey
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-07-25 18:06:56 +03:00

26 lines
789 B
Python

import json
from neo3 import wallet
def dict_to_attrs(attrs: dict) -> str:
"""
This function takes a dictionary of object's attributes and converts them
into string. The string is passed to `--attributes` key of neofs-cli.
Args:
attrs (dict): object attributes in {"a": "b", "c": "d"} format.
Returns:
(str): string in "a=b,c=d" format.
"""
return ",".join(f"{key}={value}" for key, value in attrs.items())
def pub_key_hex(wallet_path: str, wallet_password=""):
wallet_content = ''
with open(wallet_path) as out:
wallet_content = json.load(out)
wallet_from_json = wallet.Wallet.from_json(wallet_content, password=wallet_password)
pub_key_64 = str(wallet_from_json.accounts[0].public_key)
return pub_key_64