Skip to content

Config

set_google_application_credentials(json_path)

Receives the json_path credentials as a parameter,move the file to the configuration directory and update its path in the configuration file

Parameters:

Name Type Description Default
json_path str

json_path credentials

required
Source code in terminal_translator/config.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def set_google_application_credentials(json_path: str) -> None:
    """Receives the json_path credentials as a parameter,move the file to the
    configuration directory and update its path in the configuration file

    Args:
        json_path (str): json_path credentials
    """
    json_path = json_path.replace("~", str(Path().home()))
    json_file = Path(json_path)
    json_file.replace(config_path.parent / json_file.name)
    console.print(
        f"The credential file has been moved to: {config_path.parent / json_file.name}",
        style="yellow",
    )

    configs_json = toml.load(config_path)
    configs_json["google_application_credentials"] = str(
        config_path.parent / json_file.name
    )

    configs_toml = toml.dumps(configs_json)
    config_path.write_text(configs_toml)
    console.print("The google aplication credential has been set", style="green")

set_project_id(credential)

Receives the project-id as a parameter and puts it in the configuration file

Parameters:

Name Type Description Default
credential str

project-id

required
Source code in terminal_translator/config.py
45
46
47
48
49
50
51
52
53
54
55
56
def set_project_id(credential: str) -> None:
    """Receives the project-id as a parameter and puts it in the configuration file

    Args:
        credential (str): project-id
    """
    configs_json = toml.load(config_path)
    configs_json["project_id"] = credential

    configs_toml = toml.dumps(configs_json)
    config_path.write_text(configs_toml)
    console.print("The project id has been set", style="green")