Skip to content

Commit

Permalink
Merge pull request #93 from lcmcninch/is92
Browse files Browse the repository at this point in the history
Ignore !Option lines
  • Loading branch information
isaacharrisholt authored Nov 3, 2024
2 parents f87abdd + 9ef5dac commit f2c2a6e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions quiffen/core/qif.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ def parse(

# Allow for comments and blank lines at the top of sections
# Also skip `!Clear:` lines to ignore flags such as `!Clear:AutoSwitch`
# Also skip `!Option:` lines to ignore flags such as `!Option:AutoSwitch`
for i, line in enumerate(section_lines):
if (
not line.strip()
or line.strip().startswith("!Clear:")
or line.strip().startswith("!Option:")
or line[0] == "#"
):
continue
Expand Down
12 changes: 12 additions & 0 deletions tests/test_files/test_option_autoswitch.qif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!Option:AutoSwitch
!Account
NMy Bank Account
D
TBank
^
!Clear:AutoSwitch
!Option:AutoSwitch
!Account
NMy Bank Account
TBank
^
16 changes: 16 additions & 0 deletions tests/test_qif.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def qif_file_with_clear_autoswitch():
return Path(__file__).parent / "test_files" / "test_clear_autoswitch.qif"


@pytest.fixture
def qif_file_with_option_autoswitch():
return Path(__file__).parent / "test_files" / "test_option_autoswitch.qif"


def test_create_qif():
"""Test creating a Qif instance"""
qif = Qif()
Expand Down Expand Up @@ -1117,3 +1122,14 @@ def test_clear_autoswitch_ignored(qif_file_with_clear_autoswitch):
qif = Qif.parse(qif_file_with_clear_autoswitch)
assert len(qif.accounts) == 1
assert list(qif.accounts.keys()) == ["My Bank Account"]


def test_option_autoswitch_ignored(qif_file_with_option_autoswitch):
"""Tests that `!Opiton:AutoSwitch` flag exported by Quicken
is ignored.
Relates to discussion #92.
"""
qif = Qif.parse(qif_file_with_option_autoswitch)
assert len(qif.accounts) == 1
assert list(qif.accounts.keys()) == ["My Bank Account"]

0 comments on commit f2c2a6e

Please sign in to comment.