Functions | Variables
testsqlite3 Namespace Reference

Functions

def print_unprocessed_attributes (node)
 
def extract_attribute (node, attribute, pnl)
 
def extract_element (node, chld, pnl)
 
def process_memberdef (node)
 
def load_xml (name)
 
def open_db (dbname)
 
def main (argv)
 

Variables

 g_conn = None
 
list val = []
 

Function Documentation

def testsqlite3.extract_attribute (   node,
  attribute,
  pnl 
)

Definition at line 18 of file testsqlite3.py.

18 def extract_attribute(node,attribute,pnl):
19  if not attribute in node.attrib:
20  return
21  pnl.append("%s = ?" % attribute)
22  val.append(node.attrib[attribute])
23  node.attrib.pop(attribute)
24 
def extract_attribute(node, attribute, pnl)
Definition: testsqlite3.py:18
def testsqlite3.extract_element (   node,
  chld,
  pnl 
)

Definition at line 25 of file testsqlite3.py.

25 def extract_element(node,chld,pnl):
26  # deal with <tag />
27  if chld.text == None:
28  if len(chld.attrib)==0:
29  node.remove(chld)
30  return
31 
32  a=chld.text.strip()
33  if not a == "":
34  pnl.append("%s =?" % chld.tag)
35  val.append(chld.text.strip())
36  else:
37  pnl.append("%s IS NULL OR %s = ''" % (chld.tag,chld.tag))
38  node.remove(chld)
39 
def extract_element(node, chld, pnl)
Definition: testsqlite3.py:25
def testsqlite3.load_xml (   name)

Definition at line 101 of file testsqlite3.py.

101 def load_xml(name):
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":
106  process_memberdef(elem)
107  print "\n== Unprocessed XML =="
108 # ET.dump(root)
109 
110 
def load_xml(name)
Definition: testsqlite3.py:101
def process_memberdef(node)
Definition: testsqlite3.py:40
def testsqlite3.main (   argv)

Definition at line 124 of file testsqlite3.py.

124 def main(argv):
125  try:
126  opts, args = getopt.getopt(argv, "hd:x:",["help"])
127  except getopt.GetoptError:
128  sys.exit(1)
129 
130  dbname=None
131  xmlfile=None
132 
133  for a, o in opts:
134  if a in ('-h', '--help'):
135  sys.exit(0)
136  elif a in ('-d'):
137  dbname=o
138  continue
139  elif a in ('-x'):
140  xmlfile=o
141  continue
142  open_db(dbname)
143  load_xml(xmlfile)
144 
def load_xml(name)
Definition: testsqlite3.py:101
def main(argv)
Definition: testsqlite3.py:124
def open_db(dbname)
Definition: testsqlite3.py:111
def testsqlite3.open_db (   dbname)

Definition at line 111 of file testsqlite3.py.

111 def open_db(dbname):
112  global g_conn
113 
114  if dbname == None:
115  dbname = "doxygen_sqlite3.db"
116 
117  if not os.path.isfile(dbname):
118  raise BaseException("No such file %s" % dbname )
119 
120  g_conn = sqlite3.connect(dbname)
121  g_conn.execute('PRAGMA temp_store = MEMORY;')
122  g_conn.row_factory = sqlite3.Row
123 
def open_db(dbname)
Definition: testsqlite3.py:111
def testsqlite3.print_unprocessed_attributes (   node)

Definition at line 14 of file testsqlite3.py.

15  for key in node.attrib:
16  print "WARNING: '%s' has unprocessed attr '%s'" % (node.tag,key)
17 
def print_unprocessed_attributes(node)
Definition: testsqlite3.py:14
def testsqlite3.process_memberdef (   node)

Definition at line 40 of file testsqlite3.py.

41  q=[]
42  for chld in node.getchildren():
43  if chld.tag == "referencedby":
44  continue
45  if chld.tag == "references":
46  continue
47  if chld.tag == "param":
48  continue
49  if chld.tag == "type":
50  continue
51  if chld.tag == "location":
52  extract_attribute(chld,"line",q)
53  extract_attribute(chld,"column",q)
54  extract_attribute(chld,"bodystart",q)
55  extract_attribute(chld,"bodyend",q)
56 
57  q.append("id_bodyfile=(select id from files where name=?)")
58  val.append(chld.attrib["bodyfile"])
59  chld.attrib.pop("bodyfile")
60 
61  q.append("id_file=(select id from files where name=?)")
62  val.append(chld.attrib["file"])
63  chld.attrib.pop("file")
64 
66  if len(chld.attrib) == 0:
67  node.remove(chld)
68  else:
69  extract_element(node,chld,q)
70 
71  for chld in node.getchildren():
72  print "WARNING: '%s' has unprocessed child elem '%s'" % (node.tag,chld.tag)
73 
74  extract_attribute(node,"kind",q)
75  extract_attribute(node,"prot",q)
76  extract_attribute(node,"static",q)
77  extract_attribute(node,"mutable",q)
78  extract_attribute(node,"const",q)
79  extract_attribute(node,"virt",q)
80  extract_attribute(node,"explicit",q)
81  extract_attribute(node,"inline",q)
82 
83  q.append("refid=?")
84  val.append(node.attrib['id'])
85  node.attrib.pop('id')
86 
88 
89  query="SELECT * FROM memberdef WHERE %s" % " AND ".join(q)
90  r=[]
91  try:
92  r = g_conn.execute(query,val).fetchall()
93  except sqlite3.OperationalError,e:
94  print "SQL_ERROR:%s"%e
95 
96  del val[:]
97  if not len(r) > 0:
98  print "TEST_ERROR: Member not found in SQL DB"
99 
100 
def extract_element(node, chld, pnl)
Definition: testsqlite3.py:25
def process_memberdef(node)
Definition: testsqlite3.py:40
def print_unprocessed_attributes(node)
Definition: testsqlite3.py:14
def extract_attribute(node, attribute, pnl)
Definition: testsqlite3.py:18

Variable Documentation

testsqlite3.g_conn = None

Definition at line 12 of file testsqlite3.py.

list testsqlite3.val = []

Definition at line 13 of file testsqlite3.py.