mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 12:41:49 +02:00
cospend compatible import
This commit is contained in:
parent
e7d991ecc2
commit
61df8aaffb
2 changed files with 9 additions and 9 deletions
|
@ -154,10 +154,15 @@ def csv2list_of_dicts(csv_to_convert):
|
|||
"""Take a csv in-memory file and turns it into
|
||||
a list of dictionnaries
|
||||
"""
|
||||
csv_file = TextIOWrapper(csv_to_convert)
|
||||
csv_file = TextIOWrapper(csv_to_convert, encoding="utf-8")
|
||||
reader = csv.DictReader(csv_file)
|
||||
result = []
|
||||
for r in reader:
|
||||
# cospend filtering
|
||||
if r["what"] == "deleteMeIfYouWant":
|
||||
continue
|
||||
elif r["what"] == "categoryname":
|
||||
break
|
||||
r["amount"] = float(r["amount"])
|
||||
r["payer_weight"] = float(r["payer_weight"])
|
||||
r["owers"] = [o.strip() for o in r["owers"].split(",")]
|
||||
|
|
|
@ -477,14 +477,9 @@ def import_project():
|
|||
# set it to project default.
|
||||
if e.get("currency", "") in ["", "XXX"]:
|
||||
e["currency"] = g.project.default_currency
|
||||
if len(e) != len(attr):
|
||||
raise ValueError(_("Invalid JSON"))
|
||||
list_attr = []
|
||||
for i in e:
|
||||
list_attr.append(i)
|
||||
list_attr.sort()
|
||||
if list_attr != attr:
|
||||
raise ValueError(_("Invalid JSON"))
|
||||
for a in attr:
|
||||
if a not in e:
|
||||
raise ValueError(_("Missing attribute {}").format(a))
|
||||
# Keep track of currencies
|
||||
currencies.add(e["currency"])
|
||||
|
||||
|
|
Loading…
Reference in a new issue