Classes | Functions
search Namespace Reference

Classes

class  Finder
 
class  MemberType
 
class  RequestType
 

Functions

def re_fn (expr, item)
 
def openDb (dbname)
 
def process (f, kind)
 
def processHref (cn, ref)
 
def serveCgi ()
 
def usage ()
 
def serveCli (argv)
 
def main (argv)
 

Function Documentation

def search.main (   argv)

Definition at line 384 of file search.py.

384 def main(argv):
385  if 'REQUEST_METHOD' in os.environ:
386  serveCgi()
387  else:
388  serveCli(argv)
389 
def serveCgi()
Definition: search.py:290
def main(argv)
Definition: search.py:384
def serveCli(argv)
Definition: search.py:328
def search.openDb (   dbname)

Definition at line 51 of file search.py.

51 def openDb(dbname):
52  if dbname == None:
53  dbname = "doxygen_sqlite3.db"
54 
55  if not os.path.isfile(dbname):
56  raise BaseException("No such file %s" % dbname )
57 
58  conn = sqlite3.connect(dbname)
59  conn.execute('PRAGMA temp_store = MEMORY;')
60  conn.row_factory = sqlite3.Row
61  conn.create_function("REGEXP", 2, re_fn)
62  return conn
def openDb(dbname)
Definition: search.py:51
def search.process (   f,
  kind 
)

Definition at line 254 of file search.py.

254 def process(f,kind):
255  request_processors = {
256  MemberType.Function: f.function,
257  MemberType.File: f.file,
258  MemberType.Define: f.macro,
259  MemberType.Variable: f.variable,
260  MemberType.Typedef: f.typedef,
261  RequestType.References: f.references,
262  RequestType.Struct: f.struct,
263  RequestType.Includers: f.includers,
264  RequestType.Includees: f.includees,
265  RequestType.Members: f.members,
266  RequestType.BaseClasses: f.baseClasses,
267  RequestType.SubClasses: f.subClasses
268  }
269  return request_processors[kind]()
def process(f, kind)
Definition: search.py:254
def search.processHref (   cn,
  ref 
)

Definition at line 271 of file search.py.

271 def processHref(cn,ref):
272  j={}
273 
274  # is it in memberdef ?
275  table="memberdef"
276  if ( cn.execute("SELECT count(*) from %s WHERE refid=?"%table,[ref] ).fetchone()[0] > 0 ):
277  for r in cn.execute("SELECT kind,id FROM %s WHERE refid='%s'" % (table,ref) ).fetchall():
278  f=Finder(cn,r['id'],int)
279  j=process(f,str(r['kind']))
280 
281  # is it in compounddef ?
282  table="compounddef"
283  if ( cn.execute("SELECT count(*) from %s WHERE refid=?"%table,[ref]).fetchone()[0] > 0 ):
284  for r in cn.execute("SELECT id FROM %s WHERE refid=?"%table,[ref] ).fetchall():
285  f=Finder(cn,r['id'],int)
286  j=process(f,RequestType.Struct)
287 
288  return j
def process(f, kind)
Definition: search.py:254
def processHref(cn, ref)
Definition: search.py:271
static QCString str
def search.re_fn (   expr,
  item 
)

Definition at line 47 of file search.py.

47 def re_fn(expr, item):
48  reg = re.compile(expr, re.I)
49  return reg.search(item) is not None
50 
def re_fn(expr, item)
Definition: search.py:47
def search.serveCgi ( )

Definition at line 290 of file search.py.

290 def serveCgi():
291  import cgi
292 
293  print 'Content-Type: application/json\n'
294 
295  fieldStorage = cgi.FieldStorage()
296  form = dict((key, fieldStorage.getvalue(key)) for key in fieldStorage.keys())
297 
298  if 'href' in form:
299  ref = form['href']
300  else:
301  print '{"result": null, "error": "no refid given"}'
302  sys.exit(0)
303 
304  cn=openDb('doxygen_sqlite3.db')
305 
306  j = processHref(cn,ref)
307 
308  print json.dumps({"result":j,"error":None})
def openDb(dbname)
Definition: search.py:51
def serveCgi()
Definition: search.py:290
def processHref(cn, ref)
Definition: search.py:271
def search.serveCli (   argv)

Definition at line 328 of file search.py.

328 def serveCli(argv):
329  try:
330  opts, args = getopt.getopt(argv, "hr:RI:i:d:f:m:t:v:H:M:B:S:F:",["help"])
331  except getopt.GetoptError:
332  usage()
333  sys.exit(1)
334 
335  ref=None
336  dbname=None
337  j={}
338  global g_use_regexp
339 
340  for a, o in opts:
341  if a in ('-h', '--help'):
342  usage()
343  sys.exit(0)
344  elif a in ('-d'):
345  dbname=o
346  continue
347  elif a in ('-r'):
348  kind=RequestType.References
349  elif a in ('-R'):
350  g_use_regexp=True
351  continue
352  elif a in ('-I'):
353  kind=RequestType.Includers
354  elif a in ('-i'):
355  kind=RequestType.Includees
356  elif a in ('-M'):
357  kind=RequestType.Members
358  elif a in ('-B'):
359  kind=RequestType.BaseClasses
360  elif a in ('-S'):
361  kind=RequestType.SubClasses
362  elif a in ('-f'):
363  kind=MemberType.Function
364  elif a in ('-F'):
365  kind=MemberType.File
366  elif a in ('-m'):
367  kind=MemberType.Define
368  elif a in ('-t'):
369  kind=MemberType.Typedef
370  elif a in ('-v'):
371  kind=MemberType.Variable
372  elif a in ('-H'):
373  ref = o
374 
375  cn=openDb(dbname)
376  f=Finder(cn,o)
377  if ref != None:
378  j=processHref(cn,ref)
379  else:
380  j=process(f,kind)
381  print json.dumps(j,indent=4)
382 
383 
def openDb(dbname)
Definition: search.py:51
def process(f, kind)
Definition: search.py:254
def processHref(cn, ref)
Definition: search.py:271
def usage()
Definition: search.py:310
def serveCli(argv)
Definition: search.py:328
def search.usage ( )

Definition at line 310 of file search.py.

310 def usage():
311  print >>sys.stderr,"""Usage: search.py [Options]
312 Options:
313  -h, --help
314  -d <D> Use database <D> for queries.
315  -f <F> Search for definition of function <F>.
316  -m <M> Search for definition of macro <M>.
317  -r <F> Search for references to function <F>.
318  -t <T> Search for definition of type <T>.
319  -v <V> Search for definition of variable <V>.
320  -I <I> What files are including <I>.
321  -i <i> What files are included by <i>.
322  -B <C> Get the base classes of class <C>.
323  -M <C> Get all members of class <C>.
324  -S <C> Get the sub classes of class <C>.
325  -R Consider the search <term> to be a regex.
326 """
def usage()
Definition: search.py:310