diff options
author | christopherlam <christopher.lck@gmail.com> | 2017-02-05 14:58:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-05 14:58:04 +0800 |
commit | 716e127e1a46974c58139f3ab6bff9ed92196a00 (patch) | |
tree | d4f7a516793d356f12ee49d41da6dc2ad245d8e6 /gnucashxml.py | |
parent | 42193fbc3da0e2776f5a2e49b90f4fef5ed948de (diff) |
Bugfix pricedb may not exist
Diffstat (limited to 'gnucashxml.py')
-rw-r--r-- | gnucashxml.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gnucashxml.py b/gnucashxml.py index 76ba930..95e99ab 100644 --- a/gnucashxml.py +++ b/gnucashxml.py @@ -238,7 +238,14 @@ class Price(object): self.value, self.currency) - + def __lt__(self, other): + # For sorted() only + if isinstance(other, Price): + return self.date < other.date + else: + False + + ################################################################## # XML file parsing @@ -291,9 +298,10 @@ def _book_from_tree(tree): prices = [] t = tree.find('{http://www.gnucash.org/XML/gnc}pricedb') - for child in t.findall('price'): - price = _price_from_tree(child, commoditydict) - prices.append(price) + if t: + for child in t.findall('price'): + price = _price_from_tree(child, commoditydict) + prices.append(price) root_account = None accounts = [] |