-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpatch_ppxml2db.diff
More file actions
82 lines (69 loc) · 3.25 KB
/
patch_ppxml2db.diff
File metadata and controls
82 lines (69 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Submodule ppxml2db contains modified content
diff --git a/ppxml2db/ppxml2db.py b/ppxml2db/ppxml2db.py
index f3cd053..9cf668c 100644
--- a/ppxml2db/ppxml2db.py
+++ b/ppxml2db/ppxml2db.py
@@ -9,8 +9,8 @@ import os.path
import lxml.etree as ET
-from version import __version__
-import dbhelper
+from .version import __version__
+from . import dbhelper
_log = logging.getLogger(__name__)
@@ -380,7 +380,7 @@ class PortfolioPerformanceXML2DB:
d = self.parse_entry(prop_el)
assert d[0][0] == "string"
assert d[1][0] == "string"
- fields = {"name": d[0][1], "value": d[1][1]}
+ fields = {"name": d[0][1], "value": d[1][1] if d[1][1] is not None else ""}
dbhelper.insert("property", fields)
def handle_client(self, el):
@@ -389,9 +389,10 @@ class PortfolioPerformanceXML2DB:
for n in props:
dbhelper.insert("property", {"name": n, "value": fields[n], "special": 1})
- def __init__(self, xml):
+ def __init__(self, xml, skip_prices=False):
self.xml = xml
self.refcache = {}
+ self.skip_prices = skip_prices
def parse(self):
props = ["version", "baseCurrency"]
@@ -487,7 +488,7 @@ class PortfolioPerformanceXML2DB:
self.id2uuid_map[self.cur_xmlid] = el.text
elif el.tag == "price":
- if not args.skip_prices:
+ if not self.skip_prices:
self.handle_price(el)
elif el.tag == "latest":
self.handle_latest(el)
@@ -554,7 +555,10 @@ class PortfolioPerformanceXML2DB:
else:
assert False, "Unexpected crossEntry class: " + parent.get("class")
- assert self.uuid2ctr_map[uuid].startswith(what), self.uuid2ctr_map[uuid]
+ if what == "account":
+ assert self.is_account_tag(self.uuid2ctr_map[uuid]), self.uuid2ctr_map[uuid]
+ else:
+ assert self.uuid2ctr_map[uuid].startswith(what), self.uuid2ctr_map[uuid]
self.handle_xact(what, uuid, el, 0)
elif el.tag == "transactionFrom":
if el.get("id"):
@@ -606,7 +610,7 @@ class PortfolioPerformanceXML2DB:
preserve = True
elif self.el_stack and self.el_stack[-1] == "watchlist" and el.tag == "securities":
preserve = True
- elif self.container_stack and self.container_stack[-1][0] in ("security", "account", "portfolio") and el.tag == "attributes":
+ elif self.container_stack and self.container_stack[-1][0] in ("security", "account", "portfolio", "accountFrom", "accountTo", "referenceAccount", "portfolioFrom", "portfolioTo") and el.tag == "attributes":
preserve = True
if not preserve:
diff --git a/ppxml2db/ppxml2db_init.py b/ppxml2db/ppxml2db_init.py
index 8784dc4..2e8918c 100644
--- a/ppxml2db/ppxml2db_init.py
+++ b/ppxml2db/ppxml2db_init.py
@@ -2,8 +2,8 @@ import sys
import argparse
import logging
-from version import __version__
-import dbhelper
+from .version import __version__
+from . import dbhelper
SCHEMA = [