2 from xml.etree
import cElementTree
as ET
15 for key
in node.attrib:
16 print "WARNING: '%s' has unprocessed attr '%s'" % (node.tag,key)
19 if not attribute
in node.attrib:
21 pnl.append(
"%s = ?" % attribute)
22 val.append(node.attrib[attribute])
23 node.attrib.pop(attribute)
28 if len(chld.attrib)==0:
34 pnl.append(
"%s =?" % chld.tag)
35 val.append(chld.text.strip())
37 pnl.append(
"%s IS NULL OR %s = ''" % (chld.tag,chld.tag))
42 for chld
in node.getchildren():
43 if chld.tag ==
"referencedby":
45 if chld.tag ==
"references":
47 if chld.tag ==
"param":
49 if chld.tag ==
"type":
51 if chld.tag ==
"location":
57 q.append(
"id_bodyfile=(select id from files where name=?)")
58 val.append(chld.attrib[
"bodyfile"])
59 chld.attrib.pop(
"bodyfile")
61 q.append(
"id_file=(select id from files where name=?)")
62 val.append(chld.attrib[
"file"])
63 chld.attrib.pop(
"file")
66 if len(chld.attrib) == 0:
71 for chld
in node.getchildren():
72 print "WARNING: '%s' has unprocessed child elem '%s'" % (node.tag,chld.tag)
84 val.append(node.attrib[
'id'])
89 query=
"SELECT * FROM memberdef WHERE %s" %
" AND ".join(q)
92 r = g_conn.execute(query,val).fetchall()
93 except sqlite3.OperationalError,e:
94 print "SQL_ERROR:%s"%e
98 print "TEST_ERROR: Member not found in SQL DB" 102 context = ET.iterparse(name, events=(
"start",
"end"))
103 event, root = context.next()
104 for event, elem
in context:
105 if event ==
"end" and elem.tag ==
"memberdef":
107 print "\n== Unprocessed XML ==" 115 dbname =
"doxygen_sqlite3.db" 117 if not os.path.isfile(dbname):
118 raise BaseException(
"No such file %s" % dbname )
120 g_conn = sqlite3.connect(dbname)
121 g_conn.execute(
'PRAGMA temp_store = MEMORY;')
122 g_conn.row_factory = sqlite3.Row
126 opts, args = getopt.getopt(argv,
"hd:x:",[
"help"])
127 except getopt.GetoptError:
134 if a
in (
'-h',
'--help'):
145 if __name__ ==
'__main__':
def extract_element(node, chld, pnl)
def process_memberdef(node)
def print_unprocessed_attributes(node)
def extract_attribute(node, attribute, pnl)