<commit_before>import os
import sys
from iroha_cli.exception import CliException

BASE_NAME = "iroha-mizuki-cli"


def load_config(file_path):
    if not file_path:
        raise CliException("File path is not setted")

    import yaml
    try:
        with open(file_path, "r") as conf_file:
            data = yaml.load(conf_file, yaml.SafeLoader)

        account = data["account"]
        peer = data["peer"]

        try:
            with open(data["account"].get("publicKeyPath"), "r") as pubKeyFile:
                publicKey = pubKeyFile.read()
            with open(data["account"].get("privateKeyPath"), "r") as priKeyFile:
                privateKey = priKeyFile.read()
        except FileNotFoundError:
            raise CliException("File not found : {} or {} ".format(
                data["account"].get("publicKeyPath"), data["account"].get("privateKeyPath")))

        return {
            "name": account.get("name"),
            "publicKey": publicKey,
            "privateKey": privateKey,
            "address": peer.get("address"),
            "port": peer.get("port")
        }
    except yaml.YAMLError as exc:
        print("[{}] Error while parsing YAML file:".format(BASE_NAME))
        if hasattr(exc, 'problem_mark'):
            if exc.context is not None:
                print("""
                [{}] 
                  parser says
                  -----------
                  {}
                  {} {}
                  Could you correct it?
                """.format(
                    BASE_NAME,
                    exc.problem_mark,
                    exc.problem,
                    exc.context
                ))
            else:
                print("""
                [{}] 
                  parser says
                  -----------
                  {}
                  {}
                  Could you correct it?
                """.format(
                    BASE_NAME,
                    exc.problem_mark,
                    exc.problem
                ))
            sys.exit(1)
        else:
            print("[{}] Something went wrong while parsing yaml file".format(BASE_NAME))
            sys.exit(1)
    except FileNotFoundError as e:
        raise CliException("Not found config.yml {}".format(BASE_NAME, file_path))


def save_config(filename_base, data):
    import yaml
    conf_path = "config.yml"
    dumped_conf = yaml.dump(data, default_flow_style=False)

    try:
        with open(conf_path, "w") as conf_file:
            conf_file.write(dumped_conf)
    except (OSError, IOError) as e:
        print(e)
        raise CliException("Cannot open : {name}".format(name=conf_path))


def save_keypair(account_id, key_pair):
    base = '{}/.irohac'.format(os.environ['HOME'])
    os.makedirs('{}/.irohac'.format(os.environ['HOME']), exist_ok=True)
    try:
        if os.path.exists("{}/{}.pub".format(base, account_id)) or \
                os.path.exists("{}/{}".format(base, account_id)):
            raise CliException("Aleady key pair '{name}' exists!! ".format(name=account_id))<commit_msg>Remove unused function from file_io<commit_after>import os
import sys
from iroha_cli.exception import CliException

BASE_NAME = "iroha-mizuki-cli"

def save_keypair(account_id, key_pair):
    base = '{}/.irohac'.format(os.environ['HOME'])
    os.makedirs('{}/.irohac'.format(os.environ['HOME']), exist_ok=True)
    try:
        if os.path.exists("{}/{}.pub".format(base, account_id)) or \
                os.path.exists("{}/{}".format(base, account_id)):
            raise CliException("Aleady key pair '{name}' exists!! ".format(name=account_id))
{'fraction_non_alphanumeric': 0.13713021841304948, 'fraction_numerical': 0.000552944429084877, 'mean_word_length': 1.795981452859351, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7017249', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1009, 'n_words': 217}