Formatting
This commit is contained in:
parent
66c1150f60
commit
820f2daba4
3 changed files with 4 additions and 3 deletions
|
@ -42,10 +42,12 @@ def check_single_profile():
|
||||||
print("--profile is required when you have more than one database.")
|
print("--profile is required when you have more than one database.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def list_profiles():
|
def list_profiles():
|
||||||
files = os.listdir(f"{DATA_DIR}/databases")
|
files = os.listdir(f"{DATA_DIR}/databases")
|
||||||
return [x.split(".")[0] for x in files]
|
return [x.split(".")[0] for x in files]
|
||||||
|
|
||||||
|
|
||||||
def get_session(profile_name):
|
def get_session(profile_name):
|
||||||
if not profile_name:
|
if not profile_name:
|
||||||
profile_name = check_single_profile()
|
profile_name = check_single_profile()
|
||||||
|
|
3
info.py
3
info.py
|
@ -5,6 +5,7 @@ from helper import get_session, list_profiles, build_database_filename, build_ru
|
||||||
import sys
|
import sys
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
||||||
@click.command(name="info")
|
@click.command(name="info")
|
||||||
def command():
|
def command():
|
||||||
for profile in list_profiles():
|
for profile in list_profiles():
|
||||||
|
@ -19,7 +20,7 @@ def command():
|
||||||
unsorted = session.query(Transaction).filter(Transaction.category_id == None).count()
|
unsorted = session.query(Transaction).filter(Transaction.category_id == None).count()
|
||||||
transactions = session.query(Transaction).count()
|
transactions = session.query(Transaction).count()
|
||||||
categories = session.query(Category).count()
|
categories = session.query(Category).count()
|
||||||
unsorted_percent = round(unsorted / (transactions/100), 1)
|
unsorted_percent = round(unsorted / (transactions / 100), 1)
|
||||||
|
|
||||||
print(f"Transactions: {transactions}")
|
print(f"Transactions: {transactions}")
|
||||||
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
|
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
|
||||||
|
|
|
@ -16,7 +16,6 @@ except ImportError:
|
||||||
from yaml import Loader, Dumper
|
from yaml import Loader, Dumper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@click.command(name="validate")
|
@click.command(name="validate")
|
||||||
def command():
|
def command():
|
||||||
for profile in list_profiles():
|
for profile in list_profiles():
|
||||||
|
@ -24,7 +23,6 @@ def command():
|
||||||
db_path = build_database_filename(profile)
|
db_path = build_database_filename(profile)
|
||||||
rules_path = build_rules_filename(profile)
|
rules_path = build_rules_filename(profile)
|
||||||
|
|
||||||
|
|
||||||
# Rules
|
# Rules
|
||||||
if os.path.exists(rules_path) and os.path.isfile(rules_path):
|
if os.path.exists(rules_path) and os.path.isfile(rules_path):
|
||||||
with open(rules_path) as fh:
|
with open(rules_path) as fh:
|
||||||
|
|
Loading…
Add table
Reference in a new issue