예제 #1
0
 def inner_search(self, mdx, mdd_list, g_id, icon, dict_file, dic):
     if dic.pk == self.target_pk:
         o = SearchObject(mdx, mdd_list, dic, '')
         header = o.get_header()
         num_entrys = o.get_len()
         self.inner_dict = {'header': header, 'num_entrys': num_entrys}
         self.break_tag = True
예제 #2
0
 def inner_search(self, mdx, mdd_list, g_id, icon, dict_file, dic):
     if dic.pk == self.target_pk:
         entry_list, r_s_p1, r_s_p2, r_e_p1, r_e_p2 = SearchObject(mdx, mdd_list, dic, '') \
             .search_order_entry(self.p1, self.p2, self.num, self.direction)
         self.inner_dict = {
             'entry_list': entry_list,
             's_p1': r_s_p1,
             's_p2': r_s_p2,
             'e_p1': r_e_p1,
             'e_p2': r_e_p2
         }
         self.break_tag = True
예제 #3
0
 def inner_search(self, mdx, mdd_list, g_id, icon, dict_file, dic):
     if dic.pk == self.target_pk:
         record = SearchObject(mdx, mdd_list, dic, self.query,
                               g_id=g_id).search_record(
                                   self.start, self.end)
         self.inner_list = [{
             'mdx_name': dic.mdict_name,
             'mdx_entry': self.query,
             'mdx_record': record,
             'pk': dic.pk
         }]
         self.break_tag = True
예제 #4
0
def search_mdd(request, *args):
    dic_id = args[0]
    dic = MdictDic.objects.get(pk=dic_id)
    res_name = args[1].replace('%5C', '\\')

    res_content = ''
    mime_type = ''

    dic_name = dic.mdict_file
    if dic_name in init_vars.mdict_odict:
        item = init_vars.mdict_odict[dic_name]
        mdx = item.mdx
        mdd_list = item.mdd_list
        res_content, mime_type = SearchObject(mdx, mdd_list, dic,
                                              res_name).search_mdd()

    return HttpResponse(res_content, content_type=mime_type)
예제 #5
0
def get_content(dic, mdx, entry_list):
    p_list = []
    for entry in entry_list:
        s = entry[1]
        e = entry[2]
        p_list.append((s, e))

    record_list = SearchObject(mdx, None, get_dic_attrs(dic), '').search_record_list(p_list, raw=True)

    index_name = get_index_name_with_pk(dic.pk)

    for i in range(len(record_list)):
        entry = entry_list[i][0]
        content = record_list[i]

        # if content.startswith('@@@LINK='):
        #     continue

        yield {
            '_index': index_name,
            "entry": entry,
            "content": content,
        }
예제 #6
0
 def inner_search(self, mdx, mdd_list, g_id, icon, dict_file, dic):
     if dic.pk == self.target_pk:
         result_list = SearchObject(mdx, mdd_list, dic,
                                    '').search_key(self.query)
         s = -1
         e = -1
         r_p1 = -1
         r_p2 = -1
         r_entry = ''
         if len(result_list) > 0:
             s = result_list[0][0]
             e = result_list[0][1]
             r_p1 = result_list[0][2]
             r_p2 = result_list[0][3]
             r_entry = result_list[0][4]
         # 这里后面再处理
         self.inner_dict = {
             'start': s,
             'end': e,
             'p1': r_p1,
             'p2': r_p2,
             'entry': r_entry
         }
         self.break_tag = True
예제 #7
0
def get_list(dic, mdx, p1, p2, num, direction=1):
    s_obj = SearchObject(mdx, None, get_dic_attrs(dic), '')
    entry_list, r_s_p1, r_s_p2, r_e_p1, r_e_p2 = s_obj.search_key_list(p1, p2, num, direction)

    return {'entry_list': entry_list, 's_p1': r_s_p1, 's_p2': r_s_p2, 'e_p1': r_e_p1, 'e_p2': r_e_p2,
            'length': s_obj.get_len()}