diff options
Diffstat (limited to 'regional-currency/config.py')
-rwxr-xr-x | regional-currency/config.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/regional-currency/config.py b/regional-currency/config.py index d00ff51..a4bdf3d 100755 --- a/regional-currency/config.py +++ b/regional-currency/config.py @@ -7,9 +7,10 @@ import re import subprocess import urllib.parse import uuid -import argon2 from base64 import b64decode, b64encode from typing import Callable, Dict, TypeVar + +import argon2 from Crypto.Cipher import ChaCha20_Poly1305 from Crypto.Hash import SHA512 from Crypto.Protocol.KDF import PBKDF2 @@ -42,10 +43,7 @@ def load_conf() -> Dict[str, str]: conf = load_conf() -result_conf = { - **conf, - "CONFIG_LOADED": "y" -} +result_conf = {**conf, "CONFIG_LOADED": "y"} def add_conf(name: str, value: str): @@ -55,7 +53,7 @@ def add_conf(name: str, value: str): content = "" for key, value in conf.items(): escaped = value.replace("'", "\\'") - content += f'{key}=\'{escaped}\'\n' + content += f"{key}='{escaped}'\n" with open(CONFIG_FILE, "w") as f: f.write(content) @@ -360,16 +358,20 @@ if do_conversion: "3.1. Enter the name of the fiat currency (e.g. 'CHF'): ", "CHF", ) + ask_str( + "FIAT_BANK_NAME", + "3.2. Enter the name of your fiat bank (e.g. POSTFINANCE AG): ", + ) iban = ask_iban( "FIAT_ACCOUNT_IBAN", - "3.2. Enter the IBAN of your fiat bank account (e.g. 'CH7789144474425692816'): ", + "3.3. Enter the IBAN of your fiat bank account (e.g. 'CH7789144474425692816'): ", ) bic = ask_bic( "FIAT_ACCOUNT_BIC", - "3.3. Enter the BIC of your fiat bank account (e.g. 'POFICHBEXXX'): ", + "3.4. Enter the BIC of your fiat bank account (e.g. 'POFICHBEXXX'): ", ) name = ask_str( - "FIAT_ACCOUNT_NAME", "3.4. Enter the legal name of your fiat bank account: " + "FIAT_ACCOUNT_NAME", "3.5. Enter the legal name of your fiat bank account: " ) params = urllib.parse.urlencode({"receiver-name": name}) add_conf("CONVERSION_PAYTO", f"payto://iban/{bic}/{iban}?{params}") @@ -470,7 +472,7 @@ if ask_yes_no( content = "" for key, value in result_conf.items(): - escaped = value.replace('\'', '\\\'') - content += f'export {key}=\'{escaped}\'\n' + escaped = value.replace("'", "\\'") + content += f"export {key}='{escaped}'\n" with os.fdopen(3, "w") as f: f.write(content) |