def _run_op(rd): if is_debug: print 'rd', rd if not validate_op: return { 'err_data' : 'invalid request: validate_op failed' } cmd_type = rd['cmd_type'] if cmd_type == 'project_list': res = g_proj_d.keys() outd = { 'res' : res } return outd if cmd_type == 'query': bp = find_prj(rd) if not bp: return { 'err_data' : 'failed to find project for query %s' % rd } if rd['cmd_str'] == 'FLIST': outd = p_query_fl(bp) res = [] res.append(['file', 'path']) for r in outd['res']: res.append([os.path.basename(r), r]) outd['res'] = res return outd if rd['cmd_str'] == 'FDATA': fname = rd['req'] pdir = bp.proj_dir() if not fname.startswith(pdir): return { 'err_data' : 'file %s not in project %s' % (fname, pdir)} try: data = open(fname).read() outd = { 'res' : [ data ] } return outd except: return { 'err_data' : 'failed to read file %s' % fname } if rd['cmd_str'] == 'FCTAGS': fname = rd['req'] if not fname.startswith(bp.proj_dir()): return [] try: data = CtagsManager.ct_query(rd['req']) outd = { 'res' : [data] } return outd except: pass rquery = { 'cmd' : rd['cmd_str'], 'req' : rd['req'], 'opt' : rd.get('opt', '').split(','), 'hint_file' : rd.get('hint_file', ''), } outd = p_query(bp, rquery) if is_debug: print 'rquery', rquery return outd return { 'err_data' : 'invalid request: unknown cmd_type=%s' % cmd_type }
def _run_op(rd): if is_debug: print('rd', rd) if not validate_op: return {'err_data': 'invalid request: validate_op failed'} cmd_type = rd['cmd_type'] if cmd_type == 'project_list': res = list(g_proj_d.keys()) outd = {'res': res} return outd if cmd_type == 'query': bp = find_prj(rd) if not bp: return {'err_data': 'failed to find project for query %s' % rd} if rd['cmd_str'] == 'FLIST': outd = p_query_fl(bp) res = [] res.append(['file', 'path']) for r in outd['res']: res.append([os.path.basename(r), r]) outd['res'] = res return outd if rd['cmd_str'] == 'FDATA': fname = rd['req'] pdir = bp.proj_dir() if not fname.startswith(pdir): return { 'err_data': 'file %s not in project %s' % (fname, pdir) } try: data = open(fname).read() outd = {'res': [data]} return outd except: return {'err_data': 'failed to read file %s' % fname} if rd['cmd_str'] == 'FCTAGS': fname = rd['req'] if not fname.startswith(bp.proj_dir()): return [] try: data = CtagsManager.ct_query(rd['req']) outd = {'res': [data]} return outd except: pass rquery = { 'cmd': rd['cmd_str'], 'req': rd['req'], 'opt': rd.get('opt', '').split(','), 'hint_file': rd.get('hint_file', ''), } outd = p_query(bp, rquery) if is_debug: print('rquery', rquery) return outd return {'err_data': 'invalid request: unknown cmd_type=%s' % cmd_type}
def do_ct_query(filename, parent): page = CtagsListPage(parent) res = CtagsManager.ct_query(filename) page.ct.add_ct_result(res) parent.add_page(page, 'C') parent.sig_ed_cursor_changed.connect(page.ct.ed_cursor_changed)
def do_ct_query(filename, parent): page = CtagsListPage(parent) res = CtagsManager.ct_query(filename) page.ct.add_ct_result(res) parent.add_page(page, 'TagLists') parent.sig_ed_cursor_changed.connect(page.ct.ed_cursor_changed)