pygeek_stellar/cli_session.py
def _init_session_from_conf_file():
    """
    Initializes a session from an account stored on the configuration file. This function assumes that the
    configuration file already exists. This method can fail in the following situations:
    1: The configuration file is empty.
    2: The configuration file could not be decrypted (for example if a wrong decryption password was given).
    3: The configuration file is not a valid JSON file.
    4: The configuration file does not have the 'accounts' JSON key, or there are no accounts stored on it.
    5: The index of the configuration file account specified by the user is invalid.
    :return: Returns the initialized CLI session or None if something went wrong.
    :rtype: CliSession or None
    """
    configs_json, conf_file_password = _config_file_load()
    if configs_json is None:
        print("The configuration file is either empty, could not be decrypted or is an invalid JSON file.")
        return None

    if not _config_file_is_valid_content(configs_json):
        print("The content of the configuration file is invalid")
        return None

    n_accounts_found = _config_file_get_number_of_accounts(configs_json)
    if n_accounts_found <= 0:
        print("No accounts were found on the configuration file.")
        return None

    _config_file_print_accounts(configs_json)
    account_n = int_input('Which account do you want to use? (specify the index)') - 1
    if account_n < 0 or account_n >= n_accounts_found:
        print("Specified account index is invalid")
        return None

    name = configs_json[JSON_ACCOUNTS_TAG][account_n][JSON_ACCOUNT_NAME_TAG]
    address = configs_json[JSON_ACCOUNTS_TAG][account_n][JSON_ACCOUNT_ADDRESS_TAG]
    seed = configs_json[JSON_ACCOUNTS_TAG][account_n].get(JSON_ACCOUNT_SEED_TAG, None)
    return CliSession(name, address, seed)

    Initializes a session from an account stored on the configuration file. This function assumes that the
    configuration file already exists. This method can fail in the following situations:
    1: The configuration file is empty.
    2: The configuration file could not be decrypted (for example if a wrong decryption password was given).
    3: The configuration file is not a valid JSON file.
    4: The configuration file does not have the 'accounts' JSON key, or there are no accounts stored on it.
    5: The index of the configuration file account specified by the user is invalid.
    :return: Returns the initialized CLI session or None if something went wrong.
    :rtype: CliSession or None
    
Initializes a session from an account stored on the configuration file. This function assumes that the
configuration file already exists. This method can fail in the following situations:
1: The configuration file is empty.
2: The configuration file could not be decrypted (for example if a wrong decryption password was given).
3: The configuration file is not a valid JSON file.
4: The configuration file does not have the 'accounts' JSON key, or there are no accounts stored on it.
5: The index of the configuration file account specified by the user is invalid.
Initializes a session from an account stored on the configuration file . This function assumes that the configuration file already exists . This method can fail in the following situations : 1 : The configuration file is empty . 2 : The configuration file could not be decrypted ( for example if a wrong decryption password was given ) . 3 : The configuration file is not a valid JSON file . 4 : The configuration file does not have the ' accounts ' JSON key or there are no accounts stored on it . 5 : The index of the configuration file account specified by the user is invalid .
def _init_session_from_conf_file():
    configs_json, conf_file_password = _config_file_load()
    if configs_json is None:
        print("The configuration file is either empty, could not be decrypted or is an invalid JSON file.")
        return None
    if not _config_file_is_valid_content(configs_json):
        print("The content of the configuration file is invalid")
        return None
    n_accounts_found = _config_file_get_number_of_accounts(configs_json)
    if n_accounts_found <= 0:
        print("No accounts were found on the configuration file.")
        return None
    _config_file_print_accounts(configs_json)
    account_n = int_input('Which account do you want to use? (specify the index)') - 1
    if account_n < 0 or account_n >= n_accounts_found:
        print("Specified account index is invalid")
        return None
    name = configs_json[JSON_ACCOUNTS_TAG][account_n][JSON_ACCOUNT_NAME_TAG]
    address = configs_json[JSON_ACCOUNTS_TAG][account_n][JSON_ACCOUNT_ADDRESS_TAG]
    seed = configs_json[JSON_ACCOUNTS_TAG][account_n].get(JSON_ACCOUNT_SEED_TAG, None)
    return CliSession(name, address, seed)
def _init_session_from_conf_file ( ) : configs_json , conf_file_password = _config_file_load ( ) if configs_json is None : print ( "The configuration file is either empty, could not be decrypted or is an invalid JSON file." ) return None if not _config_file_is_valid_content ( configs_json ) : print ( "The content of the configuration file is invalid" ) return None n_accounts_found = _config_file_get_number_of_accounts ( configs_json ) if n_accounts_found <= 0 : print ( "No accounts were found on the configuration file." ) return None _config_file_print_accounts ( configs_json ) account_n = int_input ( 'Which account do you want to use? (specify the index)' ) - 1 if account_n < 0 or account_n >= n_accounts_found : print ( "Specified account index is invalid" ) return None name = configs_json [ JSON_ACCOUNTS_TAG ] [ account_n ] [ JSON_ACCOUNT_NAME_TAG ] address = configs_json [ JSON_ACCOUNTS_TAG ] [ account_n ] [ JSON_ACCOUNT_ADDRESS_TAG ] seed = configs_json [ JSON_ACCOUNTS_TAG ] [ account_n ] . get ( JSON_ACCOUNT_SEED_TAG , None ) return CliSession ( name , address , seed )
Initializes a session from an account stored on the configuration file.
Initializes a session from an account stored on the configuration file .
"""
    Initializes a session from an account stored on the configuration file. This function assumes that the
    configuration file already exists. This method can fail in the following situations:
    1: The configuration file is empty.
    2: The configuration file could not be decrypted (for example if a wrong decryption password was given).
    3: The configuration file is not a valid JSON file.
    4: The configuration file does not have the 'accounts' JSON key, or there are no accounts stored on it.
    5: The index of the configuration file account specified by the user is invalid.
    :return: Returns the initialized CLI session or None if something went wrong.
    :rtype: CliSession or None
    """
Returns the initialized CLI session or None if something went wrong.
Returns the initialized CLI session or None if something went wrong .
CliSession or None