Skip to content

Commit

Permalink
Replace beancount.utils.date_utils.parse_date_liberally with dateutil…
Browse files Browse the repository at this point in the history
… directly (#8)

* Replace beancount.utils.date_utils.parse_date_liberally with dateutil.parser

* Add explicit dependency on python-dateutil
  • Loading branch information
Yarikx authored Nov 11, 2024
1 parent 996f068 commit cba4100
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ install_requires =
openpyxl>=3.1.2,<4.0
xlrd>=2.0.1,<3.0
beangulp @ git+https://github.com/beancount/beangulp.git@master
python-dateutil>=2.9.0


[options.packages.find]
Expand Down
4 changes: 2 additions & 2 deletions src/uabean/importers/alfa_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import beangulp
from beancount.core import data, flags
from beancount.core.number import D
from beancount.utils.date_utils import parse_date_liberally
from dateutil.parser import parse as parse_date

from uabean.importers.mixins import IdentifyMixin

Expand Down Expand Up @@ -45,7 +45,7 @@ def get_csv_dict_rows(self, filename):
return list(csv.DictReader(f, delimiter=";"))

def get_date_from_row(self, row):
return parse_date_liberally(row[self.DATE_FIELD], dict(dayfirst=True))
return parse_date(row[self.DATE_FIELD], dayfirst=True).date()

def get_account_from_row(self, row):
k = (row["Валюта"], row["Наш IBAN"])
Expand Down
4 changes: 2 additions & 2 deletions src/uabean/importers/nexo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from beancount.core import data, flags
from beancount.core.amount import Amount
from beancount.core.number import D
from beancount.utils.date_utils import parse_date_liberally
from dateutil.parser import parse as parse_date

from uabean.importers.mixins import IdentifyMixin

Expand All @@ -30,7 +30,7 @@ def get_csv_reader(self, filename):
return csv.DictReader(open(filename))

def get_date_from_row(self, row):
return parse_date_liberally(row["Date / Time"])
return parse_date(row["Date / Time"]).date()

def account(self, _):
return "nexo"
Expand Down
4 changes: 2 additions & 2 deletions src/uabean/importers/procredit_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import beangulp
from beancount.core import data, flags
from beancount.core.number import D
from beancount.utils.date_utils import parse_date_liberally
from dateutil.parser import parse as parse_date

from uabean.importers.mixins import IdentifyMixin

Expand All @@ -35,7 +35,7 @@ def get_csv_reader(self, filename):
return csv.DictReader(open(filename, encoding="windows-1251"), delimiter=";")

def get_date_from_row(self, row):
return parse_date_liberally(row[self.DATE_FIELD], dict(dayfirst=True))
return parse_date(row[self.DATE_FIELD], dayfirst=True).date()

def get_account_from_row(self, row):
k = (row["Валюта"], row["Рахунок"])
Expand Down
4 changes: 2 additions & 2 deletions src/uabean/importers/tronscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from beancount.core import data, flags
from beancount.core.amount import Amount
from beancount.core.number import D
from beancount.utils.date_utils import parse_date_liberally
from dateutil.parser import parse as parse_date

from uabean.importers.mixins import IdentifyMixin

Expand All @@ -30,7 +30,7 @@ def get_csv_reader(self, filename):
return csv.DictReader(open(filename))

def get_date_from_row(self, row):
return parse_date_liberally(row["block_ts"])
return parse_date(row["block_ts"]).date()

def account(self, _):
return "tron"
Expand Down
4 changes: 2 additions & 2 deletions src/uabean/importers/ukrsib_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import beangulp
from beancount.core import data, flags
from beancount.core.number import D
from beancount.utils.date_utils import parse_date_liberally
from dateutil.parser import parse as parse_date

from uabean.importers.mixins import IdentifyMixin

Expand All @@ -34,7 +34,7 @@ def get_csv_reader(self, filename):
return csv.DictReader(open(filename, encoding="windows-1251"), delimiter=";")

def get_date_from_row(self, row):
return parse_date_liberally(row[self.DATE_FIELD], dict(dayfirst=True))
return parse_date(row[self.DATE_FIELD], dayfirst=True).date()

def get_account_from_row(self, row):
k = (row["Валюта"], row["Рахунок"])
Expand Down

0 comments on commit cba4100

Please sign in to comment.