From 0f5bb8f04da52d66b860b576bf7270bad92ed114 Mon Sep 17 00:00:00 2001 From: Felix Breidenstein Date: Sun, 29 Mar 2020 23:59:38 +0200 Subject: [PATCH] Formatting --- autosort.py | 12 ++++++------ helper.py | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/autosort.py b/autosort.py index f516720..74563b9 100644 --- a/autosort.py +++ b/autosort.py @@ -11,6 +11,7 @@ import colorful as cf from prompt_toolkit.completion import FuzzyWordCompleter from prompt_toolkit.shortcuts import prompt + def print_verbose(verbose, string): if verbose: print(string) @@ -31,17 +32,17 @@ def command(profile, dry_run, verbose): for t in unsorted: cat_name = apply_rules(t, rules) if cat_name: - short_name = (t.name[:25] if len(t.name)>25 else t.name) - short_desc = (t.description[:45] if len(t.description)>50 else t.description) - print_verbose(verbose,"{:<25} | {:<50}| {:>10}€".format(short_name, short_desc, t.amount/100)) + short_name = t.name[:25] if len(t.name) > 25 else t.name + short_desc = t.description[:45] if len(t.description) > 50 else t.description + print_verbose(verbose, "{:<25} | {:<50}| {:>10}€".format(short_name, short_desc, t.amount / 100)) print_verbose(verbose, cf.green(f"Matched '{cat_name}'")) cat_id = session.query(Category).filter(Category.name == cat_name).first() if not cat_id: cat_id = add_category(cat_name, profile, session) - matched +=1 + matched += 1 t.category_id = cat_id session.add(t) - print_verbose(verbose, "-"*90) + print_verbose(verbose, "-" * 90) print(f"Automatically matched {matched} transactions") if not dry_run: @@ -67,4 +68,3 @@ def apply_rules(t, rules): continue return r["category"] - diff --git a/helper.py b/helper.py index bf12a43..440b402 100644 --- a/helper.py +++ b/helper.py @@ -29,9 +29,11 @@ def create_dirs(): def build_database_filename(profile_name): return f"{DATA_DIR}/databases/{profile_name}.db" + def build_rules_filename(profile_name): return f"{DATA_DIR}/rules/{profile_name}.yaml" + def check_single_profile(): files = os.listdir(f"{DATA_DIR}/databases") if len(files) == 1: @@ -40,6 +42,7 @@ def check_single_profile(): print("--profile is required when you have more than one database.") sys.exit(1) + def get_session(profile_name): if not profile_name: profile_name = check_single_profile()