Add a basic SGML parser
I tried BeautifulSoup, which was okay, but was missing an understanding of how OFX does SGML. That's fine, writing my own parser was not that big of a deal
This commit is contained in:
parent
104289418b
commit
95244d2974
2 changed files with 83 additions and 0 deletions
17
tests/test_sgml.py
Normal file
17
tests/test_sgml.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import vanth.sgml
|
||||
|
||||
|
||||
def child_values(node):
|
||||
return [(child.name, child.value) for child in node.children]
|
||||
|
||||
def test_siblings():
|
||||
result = vanth.sgml.parse("<A><B><C>1<D>2<E>3</B></A>")
|
||||
assert result.name == 'A'
|
||||
assert child_values(result['B']) == [('C', '1'), ('D', '2'), ('E', '3')]
|
||||
|
||||
def test_closing():
|
||||
result = vanth.sgml.parse("<A><B><C>1</B><D><E>2</D></A>")
|
||||
assert result.name == 'A'
|
||||
assert child_values(result) == [('B', ''), ('D', '')]
|
||||
assert child_values(result['B']) == [('C', '1')]
|
||||
assert child_values(result['D']) == [('E', '2')]
|
Loading…
Add table
Add a link
Reference in a new issue