Subversion Repositories navi

Rev

Rev 89 | Rev 122 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/python
# -*- coding: utf-8 -*-

import tornado.database
import re

def getnavilist():
    ret = []
    current = u""
    db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi")
    for row in db.query("""
    SELECT *
    FROM `metaWords`
    WHERE partOfSpeech <> 'num.' AND partOfSpeech <> "prefix"
    ORDER BY CHAR_LENGTH(navi) DESC"""
):
        if row["infixes"]:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]})
        else:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]})
    db.close()
    return ret

def getnavi(word):
    ret = []
    db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi")
    for row in db.query("""
    SELECT *
    FROM `metaWords`
    WHERE navi = ?"""
,word):
        if row["infixes"]:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["infixes"].lower(), "type": row["partOfSpeech"]})
        else:
            ret.append({"id": row["id"], "navi": row["navi"], "infix": row["navi"].lower(), "type": row["partOfSpeech"]})
    db.close()
    return ret

#def gettrans(id, cod):
    #ret = []
    #if cod not in (u"est",u"ptbr",u"de",u"eng",u"all"):
        #return ret
    #db = tornado.database.Connection("127.0.0.1", "navi", user="navi", password="navi")
    #if cod == "all":
            #for row in db.query("""
            #SELECT *
            #FROM `metaWords`
            #WHERE id = ?""",idd):
                #infix = makeinfix(row)
            #ret.append([row["id"],row["navi"], infix, row["partOfSpeech"]])
    #db.close()