Skip to content

Commit

Permalink
Improve entries.prettify()
Browse files Browse the repository at this point in the history
  • Loading branch information
pylipp committed Aug 19, 2022
1 parent 9fbc106 commit fbe4d44
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions financeager/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ def append(self, base_entry):


def prettify(element, *, default_category):
"""Return element properties formatted as list. The type of the element
(recurrent or standard) is inferred by the presence of the 'frequency'
property.
"""Return element properties formatted as list. The type of the element (recurrent
or standard) is inferred by the presence of the 'frequency' property.
If the element's 'category' property is None, use 'default_category'.
:type element: dict
Expand All @@ -72,12 +71,10 @@ def prettify(element, *, default_category):
# Define order of listed properties
if recurrent:
properties = ("name", "value", "frequency", "start", "end", "category")
longest_property_length = 9 # frequency
else:
properties = ("name", "value", "date", "category")
longest_property_length = 0
for p in properties:
if len(p) > longest_property_length:
longest_property_length = len(p)
longest_property_length = 8 # category

if element["category"] is None:
element["category"] = default_category
Expand Down

0 comments on commit fbe4d44

Please sign in to comment.