def make_jianbing(query): response = query.reply() response.header.ra = 0 word = query.q.qname.label[0] desc = stardict.check(word) desc = [desc] if desc else notfound(word) # force change rtype to TXT response.rr = [] for txt in desc: # if len(txt) > 255 for part in split_len(txt, 255): response.add_answer( dnslib.RR(query.q.qname, dnslib.QTYPE.TXT, rdata=dnslib.TXT(part), ttl=5)) # no Recursion Available return response
def notfound(word): yield "No word '%s' found, did you mean:" % word for i, w in enumerate(stardict.get_close_matches(word)): yield " %d. %s %s" % (i+1, w, stardict.check(w).replace('\n', ' '))
def notfound(word): yield "No word '%s' found, did you mean:" % word for i, w in enumerate(stardict.get_close_matches(word)): yield " %d. %s %s" % (i + 1, w, stardict.check(w).replace('\n', ' '))