Skip to content

Commit

Permalink
got rid of prettytable dependency, new release
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchiLaser committed Sep 6, 2023
1 parent f1882eb commit 3e5e433
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 27 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "TimeForge"
version = "1.0.1"
version = "1.0.2"
authors = [
{ name="Michael Hohenstein", email="[email protected]" },
]
Expand All @@ -22,7 +22,6 @@ classifiers = [
]
dependencies = [
"argcomplete >= 3.0.5",
"prettytable >= 3.6.0",
"feiertage-de >= 0.1.0",
"requests >= 2.31.0",
"pypdf >= 3.10.0",
Expand Down
49 changes: 24 additions & 25 deletions src/timeforge/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,6 @@ def main():

#########################################

if args.verbose:
from prettytable import PrettyTable
tab = PrettyTable()
tab.field_names = ["Parameter", "Value"]
tab.add_row(["Name", args.name])
tab.add_row(["Month", args.month])
tab.add_row(["Year", args.year])
tab.add_row(["Working Time", args.time])
tab.add_row(["Personell number", args.personell])
tab.add_row(["Salary", str(args.salary) + '€'])
tab.add_row(["Organisation unit", args.organisation])
tab.add_row(["GF", args.g])
tab.add_row(["UB", args.u])
tab.add_row(["Verbose", args.verbose])
tab.add_row(["Output-File", args.output])
tab.add_row(["Job-task", args.job])
print(tab)

#########################################

# prevent autopep8 from moving these imports to the front
if True:
import feiertage
Expand All @@ -91,6 +71,28 @@ def main():

#########################################

if args.verbose:
core.PrintDictAsTable(
{
"Name": args.month,
"Month": args.month,
"Year": args.year,
"Working Time": args.time,
"Personell number": args.personell,
"Salary": str(args.salary) + '€',
"Organisation unit": args.organisation,
"GF": args.g,
"UB": args.u,
"Verbose": args.verbose,
"Output-File": args.output,
"Job-task": args.job,
},
"Command Line Arguments",
"Values"
)

#########################################

form_data = {
'Std': args.time,
'Summe': args.time,
Expand All @@ -116,9 +118,7 @@ def main():
#########################################

if args.verbose:
from pprint import pprint
print("\nCalculated Holidays:")
pprint(feiertage_list)
core.PrintListAsTable(feiertage_list, "Calculated Holidays")

#########################################

Expand All @@ -138,8 +138,7 @@ def main():
#########################################

if args.verbose:
print("\nForm Data:")
pprint(form_data)
core.PrintDictAsTable(form_data, "PDF Form field", "Value")

#########################################

Expand Down
25 changes: 25 additions & 0 deletions src/timeforge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ def PrintDictAsTable(dataset: dict, title_keys: str, title_values: str):
print("└─" + "─" * max_key_len + "─┴─" + "─" * max_value_len + "─┘")


def PrintListAsTable(dataset: list, title: str):
"""
This function prints a list as a table.
This is really useful for debugging purpose and will be called multiple times when the verbose flag is set.
Parameters
----------
dataset : list
The list which should be printed as a table
title : str
The title of the list
"""
max_len = len(title)
for i in dataset:
max_len = max(len(str(i)), max_len)

print("┌─" + "─" * max_len + "─┐")
print("│ " + title + " " * (max_len - len(title)) + " │")
print("├─" + "─" * max_len + "─┤")
for i in dataset:
print("│ " + str(i) + " " * (max_len - len(str(i))) + " │")
print("└─" + "─" * max_len + "─┘")


class APP_Data:

def __init__(self):
Expand Down

0 comments on commit 3e5e433

Please sign in to comment.