Revision 133
Added by Aaron Marcuse-Kubitza over 12 years ago
db_xml.py | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import sql |
7 | 7 |
import strings |
8 |
import util |
|
8 | 9 |
import xml_dom |
9 | 10 |
|
10 | 11 |
def name_of(node): return re.sub(r'^.*\.', r'', xml_dom.name_of(node)) |
... | ... | |
32 | 33 |
elif child_name == name: return child |
33 | 34 |
return None |
34 | 35 |
|
35 |
def get(db, node, pkeys=None, parent_id=None):
|
|
36 |
def get(db, node, pkeys=None): |
|
36 | 37 |
if pkeys == None: pkeys = {} |
37 | 38 |
def pkey(table): return sql.pkey(db, pkeys, table) |
38 | 39 |
|
40 |
for child in xml_dom.NodeElemIter(node): |
|
41 |
assert xml_dom.is_text(child) |
|
42 |
|
|
43 |
return [] |
|
39 | 44 |
|
40 | 45 |
def put(db, node, store_ids=False, row_ct_ref=None, pkeys=None, parent_id=None): |
41 | 46 |
# store_ids enables searching the tree for missing fields |
... | ... | |
86 | 91 |
|
87 | 92 |
def xml2db(db, node, row_ct_ref=None): |
88 | 93 |
iter_ = xml_dom.NodeElemIter(node) |
89 |
while xml_dom.is_text(iter_.curr()): iter_.next() # skip metadata
|
|
94 |
util.skip(iter_, xml_dom.is_text) # skip metadata
|
|
90 | 95 |
for child in iter_: put(db, child, True, row_ct_ref) |
Also available in: Unified diff
map: Continued to add DB input support